load a page and prefill form field

Discussion in 'Javascript' started by Barry Margolin, Jan 25, 2004.

  1. 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 ***
     
    Barry Margolin, Jan 25, 2004
    #1
    1. Advertising

  2. 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/
     
    Martin Honnen, Jan 25, 2004
    #2
    1. Advertising

  3. Barry Margolin <> wrote in message news:<>...
    > 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.
     
    Chris Riesbeck, Jan 26, 2004
    #3
  4. In article <>,
    (Chris Riesbeck) wrote:

    > Barry Margolin <> wrote in message
    > news:<>...
    > > 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 ***
     
    Barry Margolin, Jan 26, 2004
    #4
  5. Barry Margolin

    Grant Wagner Guest

    Barry Margolin wrote:

    > In article <>,
    > (Chris Riesbeck) wrote:
    >
    > > Barry Margolin <> wrote in message
    > > news:<>...
    > > > 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/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
     
    Grant Wagner, Jan 27, 2004
    #5
  6. In article <>,
    Grant Wagner <> wrote:

    > Barry Margolin wrote:
    >
    > > In article <>,
    > > (Chris Riesbeck) wrote:
    > >
    > > > Barry Margolin <> wrote in message
    > > > news:<>...
    > > > > 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 ***
     
    Barry Margolin, Jan 27, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. NotGiven
    Replies:
    3
    Views:
    364
    Michael D. Kersey
    May 13, 2004
  2. NotGiven
    Replies:
    3
    Views:
    316
    Michael D. Kersey
    May 13, 2004
  3. jonathan

    How to prefill a form

    jonathan, Jun 6, 2004, in forum: Javascript
    Replies:
    7
    Views:
    131
    Evertjan.
    Jun 7, 2004
  4. Sound
    Replies:
    2
    Views:
    461
    Randy Webb
    Sep 28, 2006
  5. Chuck

    Prefill Textfield/Textarea

    Chuck, Sep 7, 2007, in forum: Javascript
    Replies:
    2
    Views:
    112
Loading...

Share This Page