1

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:

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.

gtcompscientist
  • 671
  • 5
  • 18
  • Is the script enclosed in any kind of escaping block, like a CDATA? – RonaldBarzell Nov 28 '12 at 13:33
  • Does the character encoding of these files match the pages including them (when viewed in IE)? – Paul S. Nov 28 '12 at 13:34
  • Can you try removing the white space before the ` ` tag? I guess that's not the issue, but it's worth trying :) – Nikola Ivanov Nikolov Nov 28 '12 at 13:37
  • 1
    By looking at w3's [validator errors](http://validator.w3.org/check?uri=http%3A%2F%2Frowbotfitness.com%2F&charset=%28detect+automatically%29&doctype=Inline&group=0&verbose=1&user-agent=W3C_Validator%2F1.3) (of which there are 28), it may also be down to parse conflicts between the html/5/quirks parser and the xmlns parser.. and you also seem to have `...` – Paul S. Nov 28 '12 at 14:31

3 Answers3

3

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

Community
  • 1
  • 1
Coder
  • 2,833
  • 2
  • 22
  • 24
  • The point of setting a _?ver=_ is so if you change the version on the server, browsers don't rely on a previous cache'd version. I do believe the problem is down to character encoding though, +1 for getting an error message about it. – Paul S. Nov 28 '12 at 13:44
  • First of all, thanks for taking a look at this. Unfortunately, the JS/CSS files issue is not one that I can overcome at the moment. It's a problem perpetuated by WordPress and how they implement certain features. Second, I am trying to look into how to fix the MIME type for the files, but I'm not having much luck, could you explain that a little more? – gtcompscientist Nov 28 '12 at 14:07
  • After checking, I found the biggest problem: It was the encoding, for sure. Something in my WordPress setup switched it from UTF-8 to UTF-7 and the files were mis-matched as mentioned above. Fixing it on the WordPress side fixed it for the whole site. – gtcompscientist Nov 28 '12 at 14:49
0

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.

wegus
  • 282
  • 1
  • 9
0

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.

Community
  • 1
  • 1
Paul S.
  • 64,864
  • 9
  • 122
  • 138