HighTechTalks DotNet Forums  

How to set the focus to an anchor when "onload" of the page fires

Dotnet Scripting microsoft.public.dotnet.scripting


Discuss How to set the focus to an anchor when "onload" of the page fires in the Dotnet Scripting forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
dana lees
 
Posts: n/a

Default How to set the focus to an anchor when "onload" of the page fires - 11-23-2005 , 11:10 AM






Hello,

I have a html page with an anchor in the middle of the page:

<a name='dana' id='dana'>set focus...</a>

I would like to set the focus of the page to that anchor when the page
loads.

I'm trying to do that by calling an init() function when the page loads and
there to set the focus on the element:

document.getElementById("dana").focus();

This doesn't work...

Any ideas?

Thanks,
Dana





Reply With Quote
  #2  
Old   
Ben Dewey
 
Posts: n/a

Default Re: How to set the focus to an anchor when "onload" of the page fires - 12-20-2005 , 11:54 AM






why can't you just do a redirect to mypage.aspx#dana.

if you must use javascript:

function init()
{
window.location.href = window.location.href + "#dana";
}



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.