Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > load a page and prefill form field

Reply
Thread Tools

load a page and prefill form field

 
 
Barry Margolin
Guest
Posts: n/a
 
      01-25-2004
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,
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      01-25-2004


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/

 
Reply With Quote
 
 
 
 
Chris Riesbeck
Guest
Posts: n/a
 
      01-26-2004
Barry Margolin <> wrote in message news:<barmar->...
> 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.
 
Reply With Quote
 
Barry Margolin
Guest
Posts: n/a
 
      01-26-2004
In article < >,
(Chris Riesbeck) wrote:

> Barry Margolin <> wrote in message
> news:<barmar->...
> > 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,
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
 
Reply With Quote
 
Grant Wagner
Guest
Posts: n/a
 
      01-27-2004
Barry Margolin wrote:

> In article < >,
> (Chris Riesbeck) wrote:
>
> > Barry Margolin <> wrote in message
> > news:<barmar->...
> > > 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,
> 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 <>

* 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


 
Reply With Quote
 
Barry Margolin
Guest
Posts: n/a
 
      01-27-2004
In article <>,
Grant Wagner <> wrote:

> Barry Margolin wrote:
>
> > In article < >,
> > (Chris Riesbeck) wrote:
> >
> > > Barry Margolin <> wrote in message
> > > news:<barmar->...
> > > > 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,
> > 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,
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Prefill Textfield/Textarea Chuck Javascript 2 09-07-2007 11:02 PM
Deleting incorrect prefill form entries kaplan3jiim@comcast.net Firefox 1 01-07-2007 03:43 AM
How to prefill a form jonathan Javascript 7 06-07-2004 11:05 AM
copy and paste form RTF document into field in asp form cause it to bypass field length and javascript validation - how to overcome? NotGiven Javascript 3 05-13-2004 12:15 AM
copy and paste form RTF document into field in asp form cause it to bypass field length and javascript validation - how to overcome? NotGiven ASP General 3 05-13-2004 12:15 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57