elepha.info

IE7 Bugs: No overflow to your body

06. 02. 07.

Today, I've been developing a small elayer script for unnamed company. While testing it, I've found a nice bug in IE7 that can pretty mess up your life…

No overflow to your body. Yes! Thats right. A single script could mess my time around. But let's get to the point.

In most of my script where I use to display an e-layer, I usually set html body to width:100% and overflow:hidden. But today I noticed everything worked fine except IE7. To test it I minimized HTML document and code below is my output:

 1: <?xml version="1.0" encoding="utf-8" ?>
 2: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 3: <html>
 4:         <head>
 5:                 <title>IE7 Bug test</title>
 6:                 <style type="text/css">
 7:                 body{
 8:                         overflow: hidden;
 9:                 }
10: 
11:                 div{
12:                         width: 4000px;
13:                         height: 4000px;
14:                         background:red;
15:                 }
16:                 </style>
17:         </head>
18:         <body>
19:                 <div></div>
20:         </body>
21: </html>

IE7 will not apply overflow:hidden to body when the xml declaration and doctype is stated! It seems guys in Micro-soft messed up with Trident parser a little bit more than expected.

The easiest way (and only one I found today) how to correct it was to set same definition to html element. So while using previous contruction will not affect the gorgeous scrollbars while you don't need them using one below will.

1: html{
2:         overflow: hidden
3: }

How simple ;) So remember try to define html and body together while in css, and setting document.documentElement or document.getElementsByTagName("html")[0] while in javascript to hide scrollbars in your pages…

Good luck folks!

Comments

1. gravatar D Carter

Thank you, thank you, thank you! I've wasted so much time trying to find the issue here and this has exactly fixed it! I can't thank you enough. Great job.

Posted on 5th March 2007 | Reply to this comment

2. gravatar hrax

Reply to D Carter: with pleasure d. I'm glad it helped u.

Posted on 6th March 2007 | Reply to this comment

3. gravatar Maxwell

Wow thanks you just saved me!!! I don't even wan't to think how long it would have taken me to figure this one out :)

In my case it didn't work in IE6 either :/ using: document.body­.style.overflow

You pull my trigger then you blame my gun, and nothing pulls triggers more than IE!

Greets & Thanks, maxwell

Posted on 17th May 2007 | Reply to this comment

4. gravatar ManuMie

You are a great CSS master, thank you so much !

Posted on 1st July 2007 | Reply to this comment

5. gravatar pata

Thank you so much for posting this. Been wasting my time finding out what was wrong! IE7 again…(sigh)

Posted on 9th July 2007 | Reply to this comment

6. gravatar André

thanks man. this post save my sanity!

Posted on 23rd July 2007 | Reply to this comment

7. gravatar Tom

Hey there…

Thanks a lot for taking the time to document this!

I've spent the last 1/2 hour trying to find out why IE7 has yet more problems…

Posted on 5th October 2007 | Reply to this comment

8. gravatar Peter

Thanks, this really helped me out!

Posted on 2nd November 2007 | Reply to this comment

9. gravatar kasio

YOU

ARE

A

GOD!!!!!

Posted on 4th November 2007 | Reply to this comment

10. gravatar Alex

Thank you!

Posted on 12th February 2008 | Reply to this comment

12. gravatar Tine

Gracias :)

Posted on 5th March 2008 | Reply to this comment

13. gravatar Akila

Thanks a Lot…..Every where they have given that it will not work in IE so i was not able user that.After seeing urs i was soooooooooooo happy and it works very fine in all the browsers. Thanks a lot. :):)

Posted on 28th March 2008 | Reply to this comment

14. gravatar Claudio

Thanks a lot.

Here, in Brasil, I didn´t find no one site to help me about this.

You´re great.

Posted on 29th April 2008 | Reply to this comment

15. gravatar Kewlito

Thanks a lot.

Posted on 11th November 2008 | Reply to this comment

Submit a comment

Author info

Comment

You can respond to comment by writing [commentno] where commentno is number of comment displayed near author's name. Formatting is one of the easiest parts **text** will result in text, *text* will result into text and "Google":[http://www.google.com] will be formated into Google. No (X)HTML is allowed.


Browse by tags