I got a strange problem when IE8 reports a JavaScript error outside the script tag (or as it claims), and breaking all further JS on the page. Here is the violation code:
<script type="text/javascript">//<![CDATA[ function emailReport() { var params = window.location.search; var url = "scripts/someScript.php" + params; ajaxwl(url, false, null, function() { alert("Report successfully sent."); }); } //]]></script> <h2>Analyst Report</h2>
ajaxwl () is just a wrapper over jQuery.ajax () and is used in hundreds of places around the site without any problems.
IE claims that the syntax error (it does not specify which type) has a 23 line character with a </script>
. This is especially strange since this line has only 15 characters. However, if I check the intended location in the IE8 developer tools, it actually puts the error in the middle of the <h2>
on the next line.
Here is the official IE error message:
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E; InfoPath.1; MS-RTC LM 8) Timestamp: Tue, 12 Jun 2012 21:19:38 UTC Message: Syntax error Line: 175 Char: 23 Code: 0
Given that IE is not telling me the actual error message, I have not yet been able to find anything about this on the Internet. JSLint provides nothing useful, and it works flawlessly in Chrome and FF. Am I missing something?
EDIT: My hunch is that even though IE reported an error in the code snippet above, it actually dies somewhere else. This is like consensus. I think I’ll look at the page and see if I’m lucky and find an error.
source share