Internet Explorer (7-8-9) appear to remove characters from JavaScript which breaks many features

I have a website that runs on WordPress. The site uses several JavaScript components. Most notably the slides on the homepage, the schedule, and the contact form. All of the features work as expected in Chrome, Firefox, and other good browsers, but not in IE.

All of these features break due to problems that show up in the JavaScript. I have included several samples of what is happening below:

Read More

Error in IE Debug Console: “SCRIPT1006: Expected: ‘)’ – modernizr.foundation.js?ver=3.4.2, line 4 character 94”

m.join(a";")(b||"")

Actual file on the server:

m.join(a+";")(b||"")

Error in IE Debug Console: “SCRIPT1006: Expected: ‘)’ – jquery.js?ver=1.7.2, line 2 character 148”

d=f("<"">")

Actual file on the server:

d=f("<"+a+">")

They all follow this pattern of missing characters (most often ‘+’ signs). I am completely flummoxed as to what would cause this problem in Internet Explorer and would be relieved to know what’s going on, and how to fix it.

Related posts

Leave a Reply

3 comments

  1. It’s to do with the way you’re serving .js files. In particular your modernizr, you are bringing in as follows:

    <script type='text/javascript' src='http://rowbotfitness.com/wp-content/themes/businesspro/core/library/js/foundation/modernizr.foundation.js?ver=3.4.2'></script>
    

    (by the way, you have many JS and CSS files, it would be better if you could combine them, also your load order is a bit suspect, but that’s not the main problem)

    If you simply access the URL:

    http://rowbotfitness.com/wp-content/themes/businesspro/core/library/js/foundation/modernizr.foundation.js

    …in Firefox, then look at the error that pops up in your Firebug console, you’ll see the error that is causing you grief in IE:

    The character encoding of the plain text document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the file needs to be declared in the transfer protocol or file needs to use a byte order mark as an encoding signature.

    Not sure what is generating that JS file for you (with the ?ver=3.4.2) but you’d be better off linking straight to a JS file, and then setting up the correct MIME type in your webserver software. See here for a discussion on StackOverflow about that:

    Javascript MIME Type

  2. two ideas on that:

    • encoding mismatch! Sure that all files share the same encoding and that they match the encoding the webserver pretends to deliver?

    • sure that there are no vars that might contain a CariageReturn or LineFeed ? Comin from Databases those effects might occure. This can scramble your Sourcecode and lead to effects like you mentioend above.

  3. Your HTML is not valid and this is causing unexpected behaviour.

    The very first problem is the following

    <!-- an if list.. -->
    <!--[if (gt IE 9)|!(IE)]><!--> <html class=""> <!--<![endif]-->
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en-US">
    

    Resulting in 2 <html> elements, the second of which even defines a different parse behaviour to the DOCTYPE (because the unexpected second tag means you’re now in quirks). Once this is fixed the other error messages should make more sense.

    Additionally you are not sending any charset data with the .js files, whilst the page does have a charset defined ( utf-8 ) and this may cause an encoding conflict.