Script tag bug in Internet Explaorer!

S

SlimBiker

I found a strange IE bug today. I am using IE 6 on Win XP SP1. IF you
change your script tage from:

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

to

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

And if all the script tags have the above syntax then IE stops
rendering the page. First I thought there was a bug in my html, but
soon I realised that when I do the same on other downloaded pages also
the behaviour is replicated.
On mozilla, FF , Nscape this causes No Problem.

I am using XHTML 1.0 transitional and page validates to W3C.
Any idea why this could be???
 
S

Steve Pugh

SlimBiker said:
I found a strange IE bug today. I am using IE 6 on Win XP SP1. IF you
change your script tage from:

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

to

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

And if all the script tags have the above syntax then IE stops
rendering the page. First I thought there was a bug in my html, but
soon I realised that when I do the same on other downloaded pages also
the behaviour is replicated.
On mozilla, FF , Nscape this causes No Problem.

I am using XHTML 1.0 transitional and page validates to W3C.
Any idea why this could be???

IE doesn't do XHTML.

So to get anything at all in IE you must be serving your documents as
text/html which means that browsers in general will treat them as X
flavoured HTML rather than as real XHTML.

The infamous Appendix C of XHTML 1.0 recommends that the form <foo />
only be used for elements that are empty in HTML (e.g. <br>, <hr>,
<meta>, etc.). For all other elements you should continue using
<foo></foo>.

Steve
 
A

Andy Dingley

SlimBiker said:
<script type="text/javascript" src="./js/global.js" />
I am using XHTML 1.0 transitional and page validates to W3C.
Any idea why this could be???

Well known IE problem.

Don't serve XHTML as XML - the web (and particularly IE) just aren't
ready for it yet. If you must use XHTML, then use Appendix C as well
and serve it as text/html (search the c.i.w.a.h archives for much
discussion of this). Don't try either until you have some understanding
of DTDs.

When generating XHTML for use anywhere near a traditional HTML parser,
then make sure you avoid the XML behaviour of treating elements that
are empty and elements that have no content as equivalent. This isn't
true under SGML or HTML: <script></script> is _different_ to <script />

Only output empty elements (single empty tag) for elements that are
defined to be empty in the HTML DTD, such as <br />, <hr />, <link />
and <meta />. For <script> you MUST ensure that it never appears in
the <script /> form -- if you're using XSLT to generate your pages then
you might need to slip a white space character into it to stop "XML"
output changing it. XSLT doesn't understand Appendix C and can't
generate it automatically.
 
D

David Dorward

Steve said:
The infamous Appendix C of XHTML 1.0 recommends

And the spec (section 5.1) requires that XHTML documents served as text/html
follow those guidelines.

So serving <script /> as text/html is in violation of the standard, and thus
IE choking on it cannot be considered a bug.
 
T

Toby Inkster

David said:
And the spec (section 5.1) requires that XHTML documents served as
text/html follow those guidelines.

It says no such thing. Section 5.1 states that documents meeting
appendix C may be served as "text/html", but it does not state the
converse: that documents not meeting appendic C guidelines must
not be served as "text/html".
 
D

David Dorward

Toby said:
It says no such thing. Section 5.1 states that documents meeting
appendix C may be served as "text/html", but it does not state the
converse: that documents not meeting appendic C guidelines must
not be served as "text/html".

RFC 2854 says:

In addition, XHTML 1 defines a profile of use of XHTML which is compatible
with HTML 4.01 and which may also be labeled as text/html.

XHTML 1.0 5.1 says:

XHTML Documents which follow the guidelines set forth in Appendix C,
"HTML Compatibility Guidelines" may be labeled with the Internet Media
Type "text/html" [RFC2854], as they are compatible with most HTML
browsers.

So Appendix C documents may be served as text/html.

It also says:

Those documents, and any other document conforming to this specification,
may also be labeled with the Internet Media Type "application/xhtml+xml"
as defined in [RFC3236].

So Appendix C and non-Appendix C documents may be served as
application/xhtml+xml.

It also says:

For further information on using media types with XHTML, see the
informative note [XHTMLMIME].

Which says:

XHTML 1.0 (other) SHOULD NOT [be served as] text/html.

OK, so "SHOULD NOT" isn't as strong as "must not" and means that there "may
exist valid reasons in particular circumstances when the particular
behavior is acceptable or even useful, but the full implications should be
understood and the case carefully weighed before implementing any behavior
described with this label", but I have a hard time spotting any
circumstance where "breaking in IE" would be desirable, and the RFC and
XHTML Recommendation themselves don't at any point allow it.

Of course, for even more fun you can throw in the introduction to Appendix C
which says:

Note that this recommendation does not ... define the meaning of the
Internet Media Type text/html. For these definitions, see ... [RFC2854].

Which means that XHTML 1.0 says to see Appendix C, Appendix C says to see
RFC 2854, and RFC 2854 says to see XHTML 1.0, and you end up going around
in an infinite loop which never ends up at a point where you find out any
circumstances under which XHTML 1.0 is allowed to be served as text/html.

Just one more reason to stick to HTML 4.01 on the client side if you are
writing text/html webpages.
 
T

Toby Inkster

David said:
RFC 2854 says

Oh, you can't take that into account. It practically gives carte blanche
to serve *any* old tag soup as text/html.

| In addition to the development of standards, a wide variety of
| additional extensions, restrictions, and modifications to HTML were
| popularized by NCSA's Mosaic system and subsequently by the
| competitive implementations of Netscape Navigator and Microsoft
| Internet Explorer; these extensions are documented in numerous books
| and online guides.
| [...]
| Due to the long and distributed development of HTML, current
| practice on the Internet includes a wide variety of HTML variants.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,117
Latest member
Matilda564
Top