View Full Version : Jump to anchor tag onload

08-10-2009, 10:00 PM
Hello all,

I needs some help. I currently have a script to jump to an anchor tag when the page loads:

<script type="text/javascript">

function goToAnchor() {
location.href = "myPage.html#myAnchor";


Now, I would like to take it a step further and would like to link from page A to page B that usually takes a while to load and once the page loads, run a script to jump to the specified anchor tag on the page after everything has loaded. I know I have to add some parameters at the end of the url link on page A, but that's where I get stuck.

Can anyone please help?

08-13-2009, 08:18 PM
Do you mean:

<a href="http://www.yourdomain.com/pageb.html#anchor">Click me</a>

I'm kinda confused

08-14-2009, 02:11 PM
Thanks but...

While waiting to get help, I was able to figure out a solution to using js to force a specific anchor call to jump after the page completely loads. The reason I am doing this is because the page I am linking to with anchors takes a long time to load and a standard browser anchor link sometimes does not work 100%. With that said, I would now like to make the script I wrote universal to get ANY anchor param in the url and jump to that spot on the page. Right now it's coded to just look for "#anchor". I want to re-code it so it will look for "#" + "anyAnchorName".

Page A:

<a href="pageB.html#anchor">Click</a>

Page B:

<script type="text/javascript">
function load() {
var urllocation = location.href;
if(urllocation.indexOf("#anchor") > -1){
} else {
return false;

<body onload="load()">