Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > IE6/IE7 vs. IE8 give different document.documentElement.scrollHeight

Reply
Thread Tools

IE6/IE7 vs. IE8 give different document.documentElement.scrollHeight

 
 
Daniel Kabs
Guest
Posts: n/a
 
      04-23-2009
Hi there,

to make a long story short: in Internet Explorer 8, I am having problems
getting the correct height of the HTML element.

As you know, the HTML element is the outermost box in a document. The
W3C has standardized document.documentElement as a shortcut to this
element through client side Javascript. The height of the HTML element
can be gathered from document.documentElement.scrollHeight. See MSDN for
further reference:

documentElement Property
http://msdn.microsoft.com/en-us/libr...39(VS.85).aspx
scrollHeight Property
http://msdn.microsoft.com/en-us/libr...15(VS.85).aspx


Now document.documentElement.scrollHeight gives different results on
IE6/7 and IE8.



As an example, try this short page (which is rendered in
standards-compliant mode):

http://www.colincochrane.com/example...nsitional.html

Then execute the following Bookmarklet:

javascript:alert(document.documentElement.scrollHe ight);void(document.documentElement.style.border=" 1px
solid green");

It outputs the height of the HTML element (and creates a green border
around the HTML element to make is visually prominent).

I get the following results

IE6: 149
IE7: 149
IE8: 812

Why is this?
How can I get a consistent reading of the height of the HTML element in
all versions of IE?

Thanks for any help in advance,
Daniel
--
,-. . . .
,-. ,-. | | ,-. /,-.\ | , ,-. |-. ,-. . ,-| ,-.
| | |-' ||| `-. |,-|| |< ,-| | | `-. | | | |-'
' ' `-' `^' `-' \`-^/ ' ` `-^ ^-' `-' ' :; `-^ `-'
`-'
 
Reply With Quote
 
 
 
 
Eric Bednarz
Guest
Posts: n/a
 
      04-23-2009
Daniel Kabs <(E-Mail Removed)> writes:

> http://www.colincochrane.com/example...nsitional.html
>
> Then execute the following Bookmarklet:


Why wouldn’t you just use the console?

> javascript:alert(document.documentElement.scrollHe ight);void(document.documentElement.style.border=" 1px
> solid green");


[…]

> I get the following results
>
> IE6: 149
> IE7: 149
> IE8: 812


I get 148 in ‘IE7 Standards’ mode and 160 in ‘IE8 Standards (Page
Default)’. document.body.currentStyle.margin differs between the two
modes, so that would explain that little difference.

> Why is this?


Maybe you pushed some wrong buttons in the developer toolbar, or put
your site in the Compatibility View list without noticing.

> How can I get a consistent reading of the height of the HTML element
> in all versions of IE?


In *all* of them?
 
Reply With Quote
 
 
 
 
Daniel Kabs
Guest
Posts: n/a
 
      04-24-2009
Eric Bednarz wrote:
>> Then execute the following Bookmarklet:

>
> Why wouldn’t you just use the console?


Where is the console in IE6 and IE7?

> I get 148 in ‘IE7 Standards’ mode and 160 in ‘IE8 Standards (Page
> Default)’. document.body.currentStyle.margin differs between the two
> modes, so that would explain that little difference.


That's strange. I wonder why I get a totally different value.

> Maybe you pushed some wrong buttons in the developer toolbar, or put
> your site in the Compatibility View list without noticing.


When IE8 is in Compatibility View, navigator.userAgent should contain
the version string "MSIE 7.0". I will check this.

I will also do my tests again with a fresh installation of XP, just to
make sure.

Thanks.

Cheers
Daniel
--
,-. . . .
,-. ,-. | | ,-. /,-.\ | , ,-. |-. ,-. . ,-| ,-.
| | |-' ||| `-. |,-|| |< ,-| | | `-. | | | |-'
' ' `-' `^' `-' \`-^/ ' ` `-^ ^-' `-' ' :; `-^ `-'
`-'
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ie8!=ie8 cecile Javascript 2 05-24-2010 09:04 AM
Re: Advantages of IE8/64 over IE8/32 PA Bear [MS MVP] Windows 64bit 0 08-17-2009 09:43 PM
IE8 won't give up being default zvn[]teq[7] Computer Support 12 05-25-2009 05:03 PM
Give us 3 minutes; we give you the whole library lib Computer Support 1 02-04-2005 03:16 AM
Give us 3 minutes; we give you the whole library lib Computer Support 0 01-27-2005 07:52 AM



Advertisments