469,579 Members | 1,063 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,579 developers. It's quick & easy.

load a page and prefill form field

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?

--
Barry Margolin, ba****@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Jul 20 '05 #1
5 3096


Barry Margolin wrote:
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

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
Barry Margolin <ba****@alum.mit.edu> wrote in message news:<ba**************************@netnews.comcast .net>...
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.
Jul 20 '05 #3
In article <b7**************************@posting.google.com >,
ri******@cs.northwestern.edu (Chris Riesbeck) wrote:
Barry Margolin <ba****@alum.mit.edu> wrote in message
news:<ba**************************@netnews.comcast .net>...
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?


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?

--
Barry Margolin, ba****@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Jul 20 '05 #4
Barry Margolin wrote:
In article <b7**************************@posting.google.com >,
ri******@cs.northwestern.edu (Chris Riesbeck) wrote:
Barry Margolin <ba****@alum.mit.edu> wrote in message
news:<ba**************************@netnews.comcast .net>...
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?


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?

--
Barry Margolin, ba****@alum.mit.edu
Arlington, MA


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 <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_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-deve...upgrade_2.html
Jul 20 '05 #5
In article <40**************@agricoreunited.com>,
Grant Wagner <gw*****@agricoreunited.com> wrote:
Barry Margolin wrote:
In article <b7**************************@posting.google.com >,
ri******@cs.northwestern.edu (Chris Riesbeck) wrote:
Barry Margolin <ba****@alum.mit.edu> wrote in message
news:<ba**************************@netnews.comcast .net>...
> 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?


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?

--
Barry Margolin, ba****@alum.mit.edu
Arlington, MA


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).

--
Barry Margolin, ba****@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Wouter | last post: by
12 posts views Thread by Alan Silver | last post: by
2 posts views Thread by xenophon | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.