load a page and prefill form field

B

Barry Margolin

The online banking site I use has autofill=no set in their login form,
and I recently switched from IE to Safari, which honors this. I'd like
my account number to be filled in automatically like IE did (please, no
comments on whether this is a good idea or not, I've already had this
discussion in another group and I've decided the account number is not
something I consider a big secret, since it's visible on every check --
that's what the PIN is for).

I'm trying to do this with a bookmarklet. The following works to fill
in the account number and move focus to the PIN field:

document.Login.userNumber.value='123456789';
document.Login.password.focus()

(newlines included to make the post easier to read, they're not in the
actual bookmarklet).

But this requires me to use two bookmarks, a regular one to load the
site, and this one to fill in the field. I'd like a single bookmarklet
that does both steps at once. I tried:

window.location='https://www.directib.com/onlineserv/HB/Signon.cgi';
document.Login.userNumber.value='123456789';
document.Login.password.focus()

What am I missing?
 
M

Martin Honnen

Barry said:
The online banking site I use has autofill=no set in their login form,
and I recently switched from IE to Safari, which honors this. I'd like
my account number to be filled in automatically like IE did (please, no
comments on whether this is a good idea or not, I've already had this
discussion in another group and I've decided the account number is not
something I consider a big secret, since it's visible on every check --
that's what the PIN is for).

I'm trying to do this with a bookmarklet. The following works to fill
in the account number and move focus to the PIN field:

document.Login.userNumber.value='123456789';
document.Login.password.focus()

(newlines included to make the post easier to read, they're not in the
actual bookmarklet).

But this requires me to use two bookmarks, a regular one to load the
site, and this one to fill in the field. I'd like a single bookmarklet
that does both steps at once. I tried:

window.location='https://www.directib.com/onlineserv/HB/Signon.cgi';

How often does your bank change that page? Probably not often. Simply
save it locally, edit the HTML to preset
<input type="text" name="userName" value="123456789">
make sure you correctly set the
<form action="
so that it points to the right server and then when needed load your
local page with the userName preset. No need for JavaScript, you can
then have a bookmark with a URL to that local page
 
C

Chris Riesbeck

Barry Margolin said:
I'd like a single bookmarklet
that does both steps at once. I tried:

window.location='https://www.directib.com/onlineserv/HB/Signon.cgi';
document.Login.userNumber.value='123456789';
document.Login.password.focus()

What am I missing?

Won't this try to execute the assignments before the new page is fully
loaded?

If that's the cause of the problem, you could try putting the
assignments in a setTimeout(). Never tried that in a bookmarklet
though.
 
B

Barry Margolin

Won't this try to execute the assignments before the new page is fully
loaded?

That's what I think is happening. If I click on the bookmarklet a
second time, I briefly see the value pop into the field before the page
is loaded again.
If that's the cause of the problem, you could try putting the
assignments in a setTimeout(). Never tried that in a bookmarklet
though.

That's seems like a pretty unreliable way to do it. Is there any way to
load a page synchronously, so the next statement won't be executed until
it's finished?
 
G

Grant Wagner

Barry said:
That's what I think is happening. If I click on the bookmarklet a
second time, I briefly see the value pop into the field before the page
is loaded again.


That's seems like a pretty unreliable way to do it. Is there any way to
load a page synchronously, so the next statement won't be executed until
it's finished?

You're right, it's an unreliable way to do it, and I'm surprised you're
getting any result close to what you want.

As soon as window.location='...' executes, the current page UNLOADS from the
Web browser, including any script following it. The last thing you can
reliably expect JavaScript to do in the script you've presented is to
navigate your browser to https://www.directib.com/onlineserv/HB/Signon.cgi.

After that, the current page is unloaded, including the lines that attempt
to set document.Login.whatever.

--
| Grant Wagner <[email protected]>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-developer/upgrade_2.html
 
B

Barry Margolin

Grant Wagner said:
You're right, it's an unreliable way to do it, and I'm surprised you're
getting any result close to what you want.

As soon as window.location='...' executes, the current page UNLOADS from the
Web browser, including any script following it. The last thing you can
reliably expect JavaScript to do in the script you've presented is to
navigate your browser to https://www.directib.com/onlineserv/HB/Signon.cgi.

After that, the current page is unloaded, including the lines that attempt
to set document.Login.whatever.

Those lines aren't in the page that was unloaded, they're in a
bookmarklet (or I paste it directly into the Location bar).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top