Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > setting focus

Reply
Thread Tools

setting focus

 
 
lasher168
Guest
Posts: n/a
 
      06-20-2006
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

 
Reply With Quote
 
 
 
 
Randy Webb
Guest
Posts: n/a
 
      06-20-2006
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/
 
Reply With Quote
 
 
 
 
Bart Van der Donck
Guest
Posts: n/a
 
      06-20-2006
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

 
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
emulating window.focus in Body onload() event and setting focus to a control on same page Jason ASP .Net 4 05-07-2007 05:54 PM
this.window.focus() vs. window.focus() vs. this.focus() Roger Javascript 3 03-08-2007 08:53 PM
Fuji EXIF: Focus warning: "Out of focus" Hasan Diwan Digital Photography 3 12-26-2004 04:13 AM
Pan Focus vs Auto Focus JethroUK© Digital Photography 2 08-11-2004 06:26 PM
any manual focus cameras easy to focus? Catherine Jo Morgan Digital Photography 6 11-05-2003 06:36 PM



Advertisments