views:

2981

answers:

2

Applying this

overflow:hidden;

to the body of my document has no effect in IE8. Any ideas why?

+2  A: 

It must be something else, because I just applied overflow:hidden on this stackoverflow page's HTML element and the scrollbar disappeared.

Could you post some more css or code?

Edit: I also tried it on the body element and it also worked.. no more scrollbar.

Thomas Stock
The code I'm using to hide scrollbars is simply this: document.body.style.overflow = 'hidden';I see the style applied when I inspect using the IE8 Developer Tools, but it has no visible effect.
morgancodes
could u use the developer tools on this stackoverflow page and apply the style here and see if it works? (maybe you have some bizar browser option set)
Thomas Stock
but my first guess would be that something else on your page is overruling the setting.
Thomas Stock
+3  A: 

It depends on whether IE8 is rendering the page in Standards or Quirks mode. For example, the following HTML will be displayed without a scrollbar:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
    <head>
     <title>test</title>
    </head>
    <body>
     <p>hello</p>
    </body>
</html>

But if you remove the doctype declaration, IE8 renders the page in Quirks mode:

<html>
    <head>
     <title>test</title>
    </head>
    <body>
     <p>hello</p>
    </body>
</html>

You can also check this by forcing the rendering mode with the Developer Tools. Press F12 on a page, and at the end of the menu bar (for some reason...) there's a "Document Mode" setting. Toggling between Standards and Quirks here should also toggle the scrollbar.

So... you need to make your page adhere to an HTML standard! It need not be XHTML Strict, it could be HTML 4, or even XHTML Transitional if you really must.

The W3C Validator can help you with any validation errors.

Graham Clark
Thanks! Much appreciated.
morgancodes