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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Go to anchor on page load on FireFox 1

Status
Not open for further replies.

Sleidia

Technical User
May 4, 2001
1,284
FR
Hi guys,

I have this in the Javascript section of my layout:
Code:
window.onload = "document.location.href = document.location + '#myanchor'
But it doesn't work on Firefox. No move at all.

So, how can I make it work without doing a <body onload="... ?
I don't want to have the code in the body tag because it would make IE wait before the page is fully loaded, which is bad because I want the anchor to be targeted before the images are finished to be downloaded.

Thanks :)


 
Hi

Correct, it should not work, as it is incorrect. The event handlers are [tt]function[/tt]s, not [tt]String[/tt]s. ( Assuming that in reality you closed the double quotes ( " ) so it is at least syntactically correct. )
Code:
window.onload = [red]function() {[/red] document.location.href = document.location + '#myanchor' [red]}[/red]
But personally I prefer :
Code:
window.onload = function() { window.location.hash = '#myanchor' }

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top