IE script tag problem

Issue:
The page not displayed in IE. "View Source" shows the full source, <title> is displayed OK, but the page is not blank. White screen of death. Nothing.

Cause:

<script type="text/javascript" src="some.js" />

Solution:

<script type="text/javascript" src="some.js"></script>

Comments:
It's probably this whole thing with the current support of XHTML. Most browsers (in their forgiveness for HTML authoring errors) interpret XHTML as HTML with some weirdly placed slashes and other noise. So for example they see <br /> as a slightly broken <br>. More about this here.
In the case above probably IE needs the end </script> tag and because it cannot find it, it treats the whole HTML document as JavaScript, apparently broken. Hence the white page with OK source and OK HTML title.

… And while on the script tag subject, "language" is not a valid XHTML Strict attribute for <script>.


Post this entry to: » del.icio.us  » Digg  » Furl  » Newsvine  » reddit  » Y!

Somewhat related posts

14 Responses to “IE script tag problem”

  1. Marco Says:

    I once wasted a full working day on this stupid problem. I finallly found the solution by applying the very last kind of stuff I always apply to a problem: trying things that sound really stupid but you're trying them anyway out of pure despair. It's completely ridiculous! Good to post about it because I'm sure I haven't been the only one struggling with this 'feature' of Internet Explorer ;)

  2. DeadMoroz Says:

    This solution seems preety valid both for HTML and XHTML:

    and coud be used for any empty elements

  3. Stoyan Says:

    Yes, DeadMoroz, it is. The problem was that IE won't support the shorthand syntax for empty elements.

  4. Alberto Says:

    "The problem was that IE won't support the shorthand syntax for empty elements."

    Which ultimately means that IE si not abiding by the PUBLISHED standard. Can't they read?

  5. A lesson in properly closing <script> tags - crazed monkey Says:

    […] Here I was thinking that my old TTC map was only helping a few dozen people a day. In goes my updated map and up go my visits by several hundred per day. It turns out that I was closing the Google Analytics script tag in the XML style (ie. <script …/>) and not as <script …></script>. The culprit? IE, of course, which doesn’t support the former. […]

  6. aguafuertes Says:

    A year and a half afer your post, this stupid IE behavior just costed me some hours. I could trace the problem, but it is always good to find a confirmation for the results of ones trial&error. Thanks!

  7. surajz Says:

    I had the same problem at work. Because I am using xsl to generate the page

    gets translated to

    so I was forced to use (a dot before the ending tag).
    .

    I hope IE fixes this bug soon.

  8. surajz Says:

    sorry the tag above did not appear

    so basically add a non white space character (in my case a dot)

    <script …/>.…></script>

  9. Niklas Says:

    Thanks a lot! This is really dumbest problems IE ever came up with. Man I was so close to check the browser Id and redirect to a "Install Firefox!"-page in case of a positive IE check!
    Thank you, you really saved IE's a**. ;) And a whole lot of my time!

  10. Bryan Says:

    I only wasted 10 minutes on this because of this post… thanks for saving me countless hours!

  11. Daniel Says:

    Thanks, that post saved my day…

  12. Re: Javascript Source File can not be directly loaded | Bla.es Says:

    […] Yes, that’s exactly it; Internet Explorer in particular will ignore everything after a tag if it is not closed with a tag. Using the XML-style closing will not work. www.phpied.com/ie-script-tag-problem/ […]

  13. Re: Javascript Source File can not be directly loaded | Bla.es Says:

    […] > Yes, that’s exactly it; Internet Explorer in particular will ignore > everything after a tag if it is not closed with a > tag. Using the XML-style closing will not work. > www.phpied.com/ie-script-tag-problem/ > > Please note this has nothing to do with Cocoon in particular but is > simply a browser issue. […]

  14. Amit Mudgal Says:

    Guys now that we know IE doesn't support tag….can someone give a work arround as i hav a requirement where I have to use the script tag as . (There is a long story behind this) I have to do this in IE itself (have got no choices)….. Can someone help????

Leave a Reply