未經贊成請勿轉載。it
在父頁面寫入:io
前提:父頁面已經加入滾動效果。console
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">event
<body onmousewheel="top.document.body.scrollTop-=event.wheelDelta">function
子頁面加入:List
<body onmousewheel="top.document.body.scrollTop-=event.wheelDelta">scroll
封裝:call
function wheel(callback){
if(navigator.userAgent.indexOf('Firefox')==-1){
if(document.attachEvent){
document.attachEvent('onmousewheel',fn);
}else{
document.addEventListener('mousewheel',fn);
}
}else{
document.addEventListener('DOMMouseScroll',fn)
}callback
function fn(ev){
var oEvent = ev || event;
top.document.body.scrollTop-=event.wheelDelta;
}
};top
調用:
//滾動條 wheel(function(isTrue){ console.log(isTrue); })