我有一个功能可以将我的索引页面滚动到特定的锚标记并更改背景图像。我现在遇到的问题是我需要使用菜单页面中的链接移动到索引页面中的锚点并更改该背景图像。我的菜单页面出现在我的索引页面的顶部。
我在索引页面中滚动的 Javascript 是:
$('-Button-to-scroll-is-clicked').click(function () {
clearInterval(ID);
$('html, body').animate({
scrollTop: $('-Anchor').position().top
},
3000);
var IntID = setInterval(changeImg, 1500);
function changeImgHome() {
$('.imagemhome').css('background', 'url(-New-Image.jpg) top center no-repeat fixed');
};
ID = IntID;
return false;
});
我用于从菜单页面滚动索引页面的 Javascript 是:
$('-Button-In-Menu-Page').click(function () {
$('html, body').animate({
scrollTop: $('-Anchor-In-Index-Page').position().top
},
3000);
return false;
});
正如我所说,我需要在我的索引页面中检查我在滚动后所处的位置(使用 window.scroll 函数),以便我可以适当地更改背景图像。