方法1:
window.οnscrοll=function(){
alert(‘first scroll’);
}
var oldMethod = window.onscroll;
if(typeof oldMethod == ‘function’){
window.onscroll = function(){
oldMethod.call(this);
alert(‘second method’);
}
}
方法2:
function addEvent(obj,type,fn){
if(obj.attachEvent){
obj.attachEvent(‘on’+type,function(){
fn.call(obj);
})
}else{
obj.addEventListener(type,fn,false);
}
}
addEvent(window,’scroll’,function(){
alert(‘first method’)
});
addEvent(window,’scroll’,function(){
alert(‘second method’)
});
方法3:
使用jquery
(document).ready(function(){(window).scroll(function(){alert(0)});
$(window).scroll(function(){alert(1)});
})
多个window.onscroll的解决方法
最新推荐文章于 2024-03-19 15:24:14 发布