setting focus

Discussion in 'Javascript' started by lasher168, Jun 20, 2006.

  1. lasher168

    lasher168 Guest

    Hi,

    I have the neccesity to place focus on a piece of text which is a cell
    inside a table. The reason why I need this is because whenever the page
    refreshes it always goes to the top of the screen and the user needs to
    scroll down to the where this information is. After the screen
    refreshes about 1 dozen times this can be quite annoying. I have tried
    a number of different things all involving focus() however with no
    luck. Any recomendations would be appreciated.

    Regards,

    Chris
     
    lasher168, Jun 20, 2006
    #1
    1. Advertising

  2. lasher168

    Randy Webb Guest

    lasher168 said the following on 6/20/2006 5:44 AM:
    > Hi,
    >
    > I have the neccesity to place focus on a piece of text which is a cell
    > inside a table. The reason why I need this is because whenever the page
    > refreshes it always goes to the top of the screen and the user needs to
    > scroll down to the where this information is.


    Put an anchor there and refresh the page to the anchor.

    > After the screen refreshes about 1 dozen times this can be quite annoying.


    It would only take 2 or 3 refreshes to annoy me, not counting having to
    scroll down to where I was. It wouldn't take a dozen times.

    > I have tried a number of different things all involving focus() however
    > with no luck. Any recomendations would be appreciated.


    That is because there is no .focus() for a non form input field such as
    a cell inside a table.

    If the anchor won't work, track the scroll position and save it in a
    cookie. Onload of the page, check the cookie and scroll back to where
    they were.

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Jun 20, 2006
    #2
    1. Advertising

  3. lasher168 wrote:

    > I have the neccesity to place focus on a piece of text which is a cell
    > inside a table. The reason why I need this is because whenever the page
    > refreshes it always goes to the top of the screen and the user needs to
    > scroll down to the where this information is. After the screen
    > refreshes about 1 dozen times this can be quite annoying. I have tried
    > a number of different things all involving focus() however with no
    > luck.


    Here is a gimme-gimme-gimme solution:

    <div style="height:800px;">&nbsp;</div>
    <table border="1">
    <tr>
    <td><a name="value">here</a></td>
    </tr>
    </table>
    <div style="height:800px;">&nbsp;</div>

    Suppose the page's name is p1.html, then a refresh to p1.html#value
    should do the trick.

    --
    Bart
     
    Bart Van der Donck, Jun 20, 2006
    #3
    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. Jason
    Replies:
    4
    Views:
    1,631
    Jason
    May 7, 2007
  2. Replies:
    2
    Views:
    343
    Thomas 'PointedEars' Lahn
    Jun 6, 2005
  3. Roger
    Replies:
    3
    Views:
    331
  4. Jeff

    manual focus vs. focus()

    Jeff, May 20, 2007, in forum: Javascript
    Replies:
    4
    Views:
    182
  5. Spizzat2
    Replies:
    2
    Views:
    181
    Spizzat2
    Jan 9, 2008
Loading...

Share This Page