简体   繁体   中英

Anchor tag page jump

This should be a simple one: I have a page with a bunch of named anchor tags. These tags are linked to from various other pages on the site. But for some reason, when I link to the page#anchor, it always jumps back to the top. For example:

http://thedenvillehub.com/test-hs/services.asp#firesetter

It goes to the correct area, but then jumps to the top.

Same thing happens if you click on a link to get to it:

http://thedenvillehub.com/test-hs/troubled.asp (click on "Juvenile Firesetter Program")

Any ideas? It works correctly in IE, but not FF or Chrome.

You have in-line JS that's causing this:

<script type="text/javascript">
// When ready...
window.addEventListener("load",function() {
    // Set a timeout...
    setTimeout(function(){
        // Hide the address bar!
        window.scrollTo(0, 1);
    }, 0);
});
</script>

This is caused by the following JavaScript:

// When ready...
window.addEventListener("load",function() {
    // Set a timeout...
    setTimeout(function(){
        // Hide the address bar!
        window.scrollTo(0, 1);
    }, 0);
});

Removing this script should solve your issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM