Careful with Script Tags in Internet Explorer
Posted: Sat Mar 10, 2007 1:07 pm
For the last week or so, I\'ve been fighting to make Internet Explorer (v6) display the content of a page I\'ve been designing for a while, after testing generally in Firefox with no problems, I came to check in IE, only to find I had -no- page content.
This was strange, as my body background-image still loaded, however I knew IE wasn\'t rendering the markup past the body tag, though it\'d still parse the actual body tag alone.
Now, once I\'d realised this, I knew it had to be something within the markup, more specifically the HEAD section. Having recently included a <script> tag, this quickly became the suspect.
Unfortunately, and possibly naively, I\'d imagined that the <script> tag, if referencing an external script file, should be self-closed, right? Wrong.
an example code would be:
[code]<script type="text/javascript" url="http://www.example.com/foo.bar" />[/code]
To me, that\'d appear as valid XHTML, as there\'s no need for anything within the script tags when referencing it externally.. though, a good lesson learned here, the solution is to always ensure there\'s a closing script tag.
Hence the solution is/was:
[code]<script type="text/javascript" url="http://www.example.com/foo.bar"></script>[/code]
Strange, really. Firefox will choose to render this anomaly correctly, gotta love IE!
This was strange, as my body background-image still loaded, however I knew IE wasn\'t rendering the markup past the body tag, though it\'d still parse the actual body tag alone.
Now, once I\'d realised this, I knew it had to be something within the markup, more specifically the HEAD section. Having recently included a <script> tag, this quickly became the suspect.
Unfortunately, and possibly naively, I\'d imagined that the <script> tag, if referencing an external script file, should be self-closed, right? Wrong.
an example code would be:
[code]<script type="text/javascript" url="http://www.example.com/foo.bar" />[/code]
To me, that\'d appear as valid XHTML, as there\'s no need for anything within the script tags when referencing it externally.. though, a good lesson learned here, the solution is to always ensure there\'s a closing script tag.
Hence the solution is/was:
[code]<script type="text/javascript" url="http://www.example.com/foo.bar"></script>[/code]
Strange, really. Firefox will choose to render this anomaly correctly, gotta love IE!