Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set focus to a div 1

Status
Not open for further replies.

markros

Programmer
May 21, 2007
3,150
US
Hi everybody,

Is it possible to set focus to a div (not a textbox)? Im trying the following code from ASP.NET application, but it is not working:
Code:
var Round = document.getElementById('round')
                           if (Round) {
                                 Round.focus;
                                 Effect.Pulsate('round',1,0.7);}
 
I don't think you can do that, but you could create an anchor, and got to it?

Max Hugen
Australia
 
Sounds like a good idea, can you give me a bit more details here?

Thanks again.
 
Try googling for: html anchor. Or go directly to for more detail.

Basically, add an anchor before your div:

<a name="GoToRound"></a><div id="round>.....</div>

In the javascript, instead of setting focus, set the href, eg:

Code:
if (round) {
    location.href="[URL unfurl="true"]http://www.myDomain.com/myPage#GoToRound";[/URL]
}

HTH

Max Hugen
Australia
 
Dan,

Would you please elaborate a bit more here? Also we're not putting anchor around div, we're placing it right before it...
 
Unfortunately the idea doesn't seem to work in my complex page :(
 
Not sure what you mean here... but can you get it to work on a 'simple' test page?

Max Hugen
Australia
 
Unfortunately I want to make it to work in my complex AJAX ASPX page :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top