SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Procrastinator Extraordinaire lucas's Avatar
    Join Date
    Oct 2000
    Location
    Springfield, Missouri, U.S.A.
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Trying to get two javascript statements to work together...

    Code:
    <script language="javascript">
    <!--
    self.location.href='#add';
    document.addform.txtTitle.focus();
    //-->
    </script>
    the self.location.href='#add' goes to a html anchor on the page, and the focus is supposed to set the cursor inside the first textbox when the statement is run.

    if i run it as is, it will go to the anchor like its supposed to, but won't put the cursor in the textbox. if i comment out the first statement, it will put the focus on the textbox.

    any idea whats going on here?

  2. #2
    SitePoint Zealot
    Join Date
    Nov 2001
    Location
    RI, USA
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    just curious

    After setting the location.href, did you try setting the focus to some other page element, and then try setting the text field?
    in1.com | Bootply - Bootstrap playground

  3. #3
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    How about this:

    Code:
    <script language="javascript">
    self.location.hash='add';
    setTimeout("document.addform.txtTitle.focus()",500);
    </script>
    aDog

  4. #4
    Procrastinator Extraordinaire lucas's Avatar
    Join Date
    Oct 2000
    Location
    Springfield, Missouri, U.S.A.
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks adog


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •