Javascript 在另一页上滚动到具有数据幻灯片属性的div

Javascript 在另一页上滚动到具有数据幻灯片属性的div,javascript,jquery,parallax,scrolltop,jquery-waypoints,Javascript,Jquery,Parallax,Scrolltop,Jquery Waypoints,我根据本教程创建了一个单页网站: 页面上的每个幻灯片都有一个数据幻灯片属性,单击导航中的相应链接时,页面将滚动到该属性。这个很好用 问题是:我还得到了包含相同导航的子页面,因此当您单击其中一个子页面上的导航链接时,它应该重定向到主页,然后使用单击的导航链接的数据幻灯片属性滚动到div 不幸的是,我对JavaScript非常陌生 我怎样才能做到这一点? 以下是滚动功能的代码: //Create a function that will be passed a slide number and t

我根据本教程创建了一个单页网站:

页面上的每个幻灯片都有一个数据幻灯片属性,单击导航中的相应链接时,页面将滚动到该属性。这个很好用

问题是:我还得到了包含相同导航的子页面,因此当您单击其中一个子页面上的导航链接时,它应该重定向到主页,然后使用单击的导航链接的数据幻灯片属性滚动到div

不幸的是,我对JavaScript非常陌生

我怎样才能做到这一点? 以下是滚动功能的代码:

//Create a function that will be passed a slide number and then will scroll to that slide using jQuery's animate. The jQuery
//easing plugin is also used, so we passed in the easing method of 'easeInOutQuint' which is available through the plugin.
function goToByScroll(dataslide) {
    htmlbody.animate({ scrollTop: $('.slide[data-slide="' + dataslide + '"]').offset().top}, 2000, 'easeInOutQuint', function () {
        $('.nav li').removeClass('active');
        $('.nav li[data-slide="' + dataslide + '"]').addClass('active');
    });
};
//When the user clicks on the navigation links, get the data-slide attribute value of the link and pass that variable to the `goToByScroll` function
links.click(function (e) {
    e.preventDefault();
    dataslide = $(this).attr('data-slide');
    goToByScroll(dataslide);
});

对于一页卷轴,我会推荐:)谢谢你的建议,我会试试:)