faqts : Computers : Programming : Languages : JavaScript : Windows

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

16 of 21 people (76%) answered Yes
Recently 4 of 9 people (44%) answered Yes

Entry

How can I get the page to scroll to an anchor without invoking the onload?

Sep 1st, 2000 10:18
Bob John, Martin Honnen,


Yes, I have a named anchor, but when I use location.hash("anchorname"), 
the page reloads and the onload is invoked. The strange thing is that, 
as a workaround, I added mirror anchors like this:
<a name=anchorname></a><a name=banchorname href=anchorname></a>
and in the javascript I call document.all.banchorname.click() I get the 
expected behavior: the document scrolls to anchorname and the onload 
does not invoke. However when I call location.hash("anchorname"), or 
any other of the possible location combinations, the page reloads and 
the onload function does it's things. 
Any ideas? or should I just stick with my workaround?