http://dabbler.org/home/asdf/scrolling/test.html
有人看到这段代码有什么问题吗?
我不知道它有什么问题,但我的意图是当用户点击页面底部时,页面会滚动到顶部。
谢谢。
最佳答案
你错过了一个右括号:
function getheight() {
var myWidth = 0,
myHeight = 0;
if (typeof (window.innerWidth) == 'number') {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
var scrolledtonum = window.pageYOffset + myHeight - 16;
var heightofbody = document.body.offsetHeight;
if (scrolledtonum = heightofbody) {
alert('asdf!')
}
//???? } <--
这是一个修复了一些代码的工作版本:http://jsfiddle.net/maniator/8zhmg/
关于javascript - 检测滚动到页面底部事件并采取行动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6666617/