scrollTop in defferent browers
shortcut.add("up",function() {
alert( document.body.scrollTop)
if (document.documentElement&& typeof document.documentElement.scrollTop=='number'){
document.documentElement.scrollTop-=100
}
else if (document.body) {
document.body.scrollTop-=100
}
})
shortcut.add("down",function() {
if (document.documentElement&&typeof document.documentElement.scrollTop=='number' ){
document.documentElement.scrollTop+=100
}
else if (document.body) 开发者_高级运维{
document.body.scrollTop+=100
}
})
it can running in firefox,but not in chrome and safari
thanks
Chrome and Safari don't like the "body" element to be the target of scrolling requests like that. I'm not sure what the details are, but it doesn't work. Instead of doing that, put your own outer-level <div>
that's sized to fill the whole <body>
, and scroll that instead.
精彩评论