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.
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.
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
(
1,
2,
3,
);
By the way, SoulScratch, how did you come up with that javascript debug info? Looks handy.
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
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.