views:

746

answers:

2

I have a JS script that works on IE8 compatibility mode, FF, Chrome, Opera, but not IE8 standards mode.

As I think standards mode is more strict than compatibility mode, maybe there's something wrong with my code. How can I debug? Is there something that shows me things that would work in compatibility mode but standard?

Also, in the short term, how can I change the user browser to use compatibility mode in JS. I don't want to change the entire site (ie, change the template doctype), how do I do it in JS?

Thanks.

+1  A: 

For forcing compatibility mode, you need a custom header. See this link http://weblogs.asp.net/joelvarty/archive/2009/03/23/force-ie7-compatibility-mode-in-ie8-with-iis-settings.aspx

If you post the Javascript that is not working, may be we can point out the problem.

Chetan Sastry
I wouldn't consider forcing compatibility mode anything other than a quick fix, though. There are lots of improvements in the IE8 engine that are lost by doing this.
Blixt
A: 

First of all, check the value of the document.documentMode value in JavaScript. If your page is in quirks mode, it goes back to IE 5 behavior, which can mess up your code.

To check the document mode, use this little piece of JavaScript.

var docMode = document.documentMode;
if (!docMode|| docMode < 8) {
    // Old IE or IE8 or later compatibility mode.
    // 5 for quirks mode, 7 for compatibility mode,
    // undefined for IE7 or earlier.
} else {
    // IE8 or later standards mode.
}

It's hard to tell what your problem is if you don't post code though. Maybe we can figure it out if you show us what code behaves differently.

Blixt