Possible Duplicate:
Making DOM IE Friendly
What I am doing wrong here? (it is supposed to be IE compliant, but it doesn’t work at all)
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);
What can I do to make it IE compliant once I have fixed it?
There is a typo in the line starting with
var scrolledtonum = ((the S in ScrollTop has to be lowercase)
Furthermore: be sure that getheight() will not be called before the document’s onload-event has fired, otherwise
document.body.offsetHeightmay not return correct values.