Reputation: 595
Ok so I'm having some strange issue with an mvc 3 site using javascript / jquery hosted locally in IIS 7.5.
When I open the site through http://localhost/..... the site works perfectly in IE 9 and firefox, when I use http://computername/..... the site doesn't work in IE. It does still work in firefox.
Looking to the script console using F12 and computername I see the following error: SCRIPT1028: Expected identifier, string or number When I use localhost this error doesn't popup.
I've tried adding the site to the trusted sites in IE, this doesn't make a change. Also I've used fiddler which shows all the needed javascript files are loaded correctly.
How can it be the difference in url obviously alters the way the javascript is interpreted? What am I missing here?
Upvotes: 0
Views: 2789
Reputation: 595
Ok so I solved it, apparently it has something to do with the compatibility mode in IE, it automatically seems to go into IE7 mode for non-localhost domains.
adding this tag to the head of the page solved the issue:
meta http-equiv="X-UA-Compatible" content="IE=9"
The next post describes a similar issue and how to solve it: https://serverfault.com/questions/142721/iis-displaying-page-differently-when-localhost-is-used-in-url-vs-hostname
this article from the msdn specifies it: http://msdn.microsoft.com/en-us/library/cc288325%28VS.85%29.aspx
Upvotes: 0
Reputation: 6780
Actually, the problem probably IS the trailing comma:
One of the reasons may be that the document on computername loads the site in "Compatibility View". The trailing comma causes syntax error in IE7 document mode. Not other versions.
Check for extra commas!
Upvotes: 1