Removing iframe Horizontal Scrollbar

Posted on February 6, 2008 at 16:14 XHTML

Oh c’mon! A few days ago, I was already about to die trying to remove a freakin’ horizontal scrollbar of the iframe in this fanlisting. The problem is only associated with Internet Explorer. :devil: The last resort I could do was to compare it line after line with another code that does not show the said scrollbar. So how did it turn out? Well, the only thing that was missing was a line before the document type declaration (DTD). I then remembered that the same thing holds true for the scrollbar colors that are not supported in Firefox (I used to do it before). So anyway, for instance, the first line of the code should not be:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Instead,

<!--anything goes here (perhaps even a blank line)-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Whew, glad I did it. And oh, please bear with the title of this post. :sweat:

On other whatnots…

8 Comments

  1. gravatar.com christel
    February 7, 2008 at 18:41

    oooooh.. spring waltz.. endless love series pala. i haven’t tried watching it.maybe i should watch one of these days.. haha i notice that everyone watches it. šŸ™‚

    good luck with your exam. šŸ™‚

    Today is Ash Wednesday, but Iā€™m not going to the church. šŸ™ Iā€™m becoming the devil. — that made me LOL. xD

    Reply

  2. gravatar.com Christian
    February 7, 2008 at 20:01

    Talaga? Fourth and last installment ng Endless Love ang Spring Waltz. Nagyon ko lang nalaman. Ang weird kasi eh, bakit ba sa 2 kasi ipinalabas. Lol. I’m not a fan of koreanovelas, madalang lang akong manood ng mga ganyan, the last koreanovela I watched was Princess Hours.

    Reply

  3. gravatar.com usame
    February 7, 2008 at 20:44

    Hello Nelson. Goodluck to that exam in OS šŸ˜€ I believe you will do well. Have a great day

    Reply

  4. gravatar.com koko
    February 9, 2008 at 18:28

    wooow… Spring waltz is an installment of the Endless Love series???

    Woah.

    ooh, Good luck with the exaaaammmm!!!! :cheerful: :angel: šŸ˜‰

    Reply

  5. gravatar.com vasaa
    August 11, 2008 at 20:26

    hi..machan(thats one of word for friend in our country..)
    thanks lot..
    i also dieying with iframe horizontal scrollbar..now fixed it..
    thanx..again.
    bye

    Reply

  6. gravatar.com Nelson
    August 11, 2008 at 20:39

    Oi,

    I’m really pleased to finally hear from someone who also finds this little ‘fix’ effective.

    Glad to be of help, machan. šŸ™‚

    Reply

  7. gravatar.com Peter
    December 2, 2008 at 18:15

    Nelson,

    The W3C specification for XHTML states “There must be a DOCTYPE declaration in the document prior to the root element” (http://www.w3.org/TR/xhtml-basic/#s2.1)

    Now exactly how this is interpreted, differs (of course) between browsers. Most browsers will allow most whitespace characters before the doctype, though Internet Explorer (versions 6 – 8b2) and Opera will not allow a non-breaking space (Alt-0160). Firefox and Safari will allow anything that is not a tag (for example ), even plain text. Internet Explorer (all versions) will not allow comments before the doctype either, but all other browsers do.

    Having illegal content before the doctype has the same effect as an invalid doctype or having no doctype at all; the page is interpreted in quirks (backwards compatibility) mode.

    Now, back to the horizontal scrollbar. I have also witnessed this, it happens in Internet Explorer 6 with iframes (and normal frames?) where the content is forced to 100% wide, and the content document is standards compliant. (Clearly a bug in IE6’s standards compliance.)

    What now, if you don’t want that scrollbar, but still needs pages that can be tested for standard compliance? Internet Explorer 6, in all it’s wisdom, does not even allow an XML declaration (for example ) before the doctype. All other browsers I tested, including newer versions of IE, do allow the XML declaration. So just add an XML declaration before the doctype of the iframe contents document, and you will not have a horizontal scrollbar anymore. Of course, this may mean you will have to deal with other weirdness in the document because it’s rendered in quirks mode in IE6 (only)….

    Some more info about quirks mode:
    http://www.cs.tut.fi/~jkorpela/quirks-mode.html
    http://www.quirksmode.org/

    Reply

  8. gravatar.com Nelson
    December 2, 2008 at 22:24

    Hello Peter,

    First of all thank you very much for the very informative comment. I think I haven’t heard anything about that that quirks mode before but I must say that for my part, even though you stated that having illegal content before the doctype has the same effect as an invalid doctype or having no doctype at all, I still consider it “harmless” by the mere basis that the validator accepted it without any warnings.

    I have tried using an XML declaration before but it didn’t turn out valid when I checked it. I didn’t know if there was only a typo but one thing’s for sure: from that day until today, I haven’t used it again and stuck to the meta tag instead. Lastly, I think there are still a lot of IE users out there who use 6.

    Reply

Say What?

Name:
E-mail:
Website: (optional)