Re: To Get the Scroll Height
Relying on the exact browser like that is bad because you will never get good cross-browser compatability. Here's a script taken from www.quirksmode.org, a great resource on cross-browser compatible JavaScript:
Code:
var x,y;
if (self.pageYOffset) // all except Explorer
{
x = self.pageXOffset;
y = self.pageYOffset;
}
else if (document.documentElement && document.documentElement.scrollTop)
// Explorer 6 Strict
{
x = document.documentElement.scrollLeft;
y = document.documentElement.scrollTop;
}
else if (document.body) // all other Explorers
{
x = document.body.scrollLeft;
y = document.body.scrollTop;
}
Re: To Get the Scroll Height
EDIT: Misunderstood the question.
Re: To Get the Scroll Height
The code I posted should work in all browsers. Yours doesn't retrieve the values he wanted (he wanted the position of the scroll, not the dimensions of the page.)
The problem he was experiencing was that once he adds the document type, IE goes into strict mode at which point you have to use document.documentElement instead of document.body.
Also, I'm pretty sure that code you posted comes from Quirksmode as well... ;)
Re: To Get the Scroll Height
Quote:
Originally Posted by andreasblixt
Also, I'm pretty sure that code you posted comes from Quirksmode as well... ;)
Really? Where? I wrote it a while back when working with an overlay script.