可能重复:
Making DOM IE Friendly
我在这里做错了什么? (它应该符合IE标准,但它根本不起作用)
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;
}
var scrolledtonum = (((t = document.documentElement) || (t = document.body.parentNode)) && typeof t.ScrollTop == 'number' ? t : document.body).ScrollTop + myHeight + 2;
alert(scrolledtonum);
var heightofbody = document.body.offsetHeight;
if (scrolledtonum >= heightofbody) {
document.body.scrollTop = 0;
}
}
window.onscroll = getheight;
function func() {
window.document.body.scrollTop++;
}
window.document.onmouseover = function () {
clearInterval(interval);
};
window.document.onmouseout = function () {
interval = setInterval(func, 20);
};
var interval = setInterval(func, 20);
一旦我修好IE,我该怎么做才能使IE兼容?
答案 0 :(得分:0)
以var scrolledtonum = (
.ScrollTop + myHeight + 2;
(ScrollTop中的S必须小写)
此外:确保在文档的onload-event被触发之前不会调用getheight(),否则document.body.offsetHeight
可能无法返回正确的值。