Javascript IE多次触发滚动事件
这是一个事件处理程序:Javascript IE多次触发滚动事件,javascript,jquery,internet-explorer,events,Javascript,Jquery,Internet Explorer,Events,这是一个事件处理程序: $(window).on("scroll", function(e){ e.stopPropagation(); e.preventDefault(); if ((window.innerHeight + document.body.scrollTop) >= document.body.scrollHeight) if (window.location.hash=
$(window).on("scroll", function(e){
e.stopPropagation();
e.preventDefault();
if ((window.innerHeight + document.body.scrollTop) >= document.body.scrollHeight)
if (window.location.hash=='#/')
window.location.hash='#/1';
else
window.location.hash='#/';
});
我有以下问题:Mozilla和Chrome的一切都很好,但是,当滚动到达页面底部时,IE会多次更改
窗口.位置.散列,这会产生问题。我如何防止在向下滚动到底部时发生多次更改?滚动
事件会快速触发,每滚动一像素最多触发一次。查看去盎司模式您是否可以在底部声明一个标志(在闭包中),并在到达底部时将其设置为true,否则将其设置为false?只有在尚未设置标志的情况下,您才会处理哈希。感谢您的建议(去盎司模式)scroll
事件会快速触发,每滚动像素最多触发一个事件。查看去盎司模式您是否可以在底部声明一个标志(在闭包中),并在到达底部时将其设置为true,否则将其设置为false?只有在尚未设置标志的情况下,您才会处理哈希。感谢您的建议(去盎司模式)