简体   繁体   中英

How do I make menu link go back to index page and slide to specific height?

I have this long index.html that has links to external pages, so my question is how to link them from those external pages back to index.html to specific height with this:

$(document).ready(function() {
$(".scroll").click(function(event){
    $('html, body').animate({scrollTop: '+= whatever px'}, 800);
});
});

To be more specific, I need files 1klopa.html and 2trattoria.html from .zip to link to index.html with implemented menu bar to specific height with above code or similar... So if someone needs whole website to understand the code it's quite long and in zip here, virus free and free to review: https://mega.co.nz/#!8lRRlSga!_R5RzEN1ZhGcyQcohOiGzjnEYYmlgN8_ANsvQ4WGNUE

I appreciate all the help.

Just add some anchors in your index.html:

<a name = "scrollTarget1"></a>

Create links from external sites to the anchor:

<a href = "index.html#scrollTarget1">Link to anchor</a>

The browser will take care of scrolling your site to the desired position and it will even work without any JavaScript invocation.

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