views:

347

answers:

2

I have made a super simple test case of a problem I'm having with IE6 and jQuery 1.3.2

In IE6 I only see the first alert box, it will render the page but it seems there is something in the js file that is causing IE6 to stop processing the scripts in the <head> content and thus not show the 2nd alert box. Chrome works as expected.

Needless to say this was a much more complicated problem, but I've managed to reduce it to this: IE6 seems to "fail" and stop processing javascript in the <head> area after loading the 1.3.2 javascript file.

Any Ideas?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html >
<head>
  <title>test</title>
  <link rel="Stylesheet" href="main.css" />
  <script type="text/javascript">
    alert("here 1");
  </script>
  <script src="jquery-1.3.2.js" type="text/javascript" />
  <script type="text/javascript">
    alert("here 2");
  </script>
</head>
<body>
nothing to see here... move along...

</body>
</html>
+4  A: 

From what I remember, you can't load a JS file without a closing tag for your script:

<script src="jquery-1.3.2.js" type="text/javascript"></script>

Give it a try and let me know if it works out!

mattbasta
+1 - I think this is the problem in IE
Russ Cam
dang that fixed it. ftw!
Hogan
Well, it's part of the XHTML 1 spec - http://www.w3.org/TR/xhtml1/#C_3
Russ Cam
@Russ - I read that line in the spec just now, and it seems to say don't use <p /> for non-empty cases -- which of course I wasn't, the content is empty. Or maybe that is not what it is saying... it is not very clear.
Hogan
@Hogan- that's not what it's saying, it's saying an element whose content model is not EMPTY should not/(cannot) use the minimized form. This includes the `<script>` element
Russ Cam
Also take a look at the spec for the `<script>` element - http://www.w3.org/TR/REC-html40/interact/scripts.html, in particular **Start tag: required, End tag: required**
Russ Cam
@Russ 18.2.1 clinches it -- but the key here is that an external source is considered content. Non-external was empty, but "content model" is not I guess. Not intuitive but understandable. Thanks Russ.
Hogan
The interesting thing here is that, going by the specs, IE6 is doing it right and Chrome is doing it wrong. Which just goes to show how much browser manufacturers are prepared to ignore the specs, to support common author mistakes.
Alohci
@Alohci which is quite ironic given that it is normally IE which ignores the specs and lets html coders write malformed html. Of course, it seems to me that the spec was written to the IE standard in this case (but I could be wrong about this.)
Hogan
+1  A: 

newbie mistake.

You can't use the short tag notation for the script element in IE6.

Use:

<script src="jquery-1.3.2.js" type="text/javascript"></script>
rjlopes
Sweet! It has been a long time since I've been called a newbie.
Hogan
it happend to me too some years ago, but in my case the whole page was blank on IE because i closed the script tag like you did. Off course it worked fine on other browsers, I ended up wasting one hour to find the source of the problem. But something good came out of that, from that time on i never ever forget that i shouldn't close the script tag like that...
rjlopes