Internet Explorer not loading external javascript

Does anybody know why Internet Explorer, both 6 and 7, don’t load the javascript files? I haven’t got a clue. Everything works fine in Firefox and Safari.

Here is the page:

<!-- In the <head> -->
<script type="text/javascript" src="./js/jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="./js/my-jquery.js"></script>

Thank you.

Line: 100
Character: 4
Code: 0
Error Message: Expected identifier, string or number

IE complains about something which I suspect is in your my-query.js script. Try commenting out different portions, it’s seeming to fail on a right hand assignment and you may just have some invalid characters in an object property, or maybe using illegal characters where they cant be used.

You have a trailing comma on line 98.

Oh boy, I could have been looking for that a long time still. Thanks a lot. Both of you.

I will keep this in mind for the future. Having not so much in experience with javascript yet, but in PHP it is perfectly valid code. I actually prefer it for multiline arrays.

$var = array

By the way, SoulScratch, how did you come up with that javascript debug info? Looks handy.

Erm - a warning came up in IE6. Another useful tool I should’ve used to pinpoint would’ve been

Yeah, I’m also used to Python where a comma doesn’t really matter, e.g. a = [1,2,3,]. ECMAScript isn’t so lenient :frowning:

Trailing commas on arrays don’t cause much trouble, it’s an object which was the issue in this situation. Still, having trailing commas in an array isn’t a good idea because IE will think the array’s length is one more than it really is.

alert( [1,2,3,].length );
// IE will alert 4
// Most other browsers will alert 3

Yeah I should’ve actually used a dictionary as an example: a={‘b’:2,} wouldn’t throw an error in Python as it would in ECMAScript.

The layout I prefer is:

var arr=


var obj=

You can then re-order or delete elements freely by deleting or moving entire lines, and there can never be an accidental trailing comma. Adding or pasting extra lines at the end does not require adding a comma to what was formerly the last line. Eachadditional line includes the comma it requires, that is, the one preceding the item. In addition to reducing errors, I also find this format easier to parse visually, since it puts all the punctuation in the same column.

The only item that is formatted differently is the first one, containing the opening brace, but it would be difficult to overlook a mistake involving that, and testing in any browser would catch it. Mistakes with trailing commas, on the other hard, are much easier to make, and if you test in Firefox, they can cause hard-to-debug problems in IE; an entire class of mistakes which this layout prevents.