IE default version is changed to 7 automatically

309 Views Asked by At

i have added the bellow piece of code in my js file.

var meta = document.createElement('meta');
meta.httpEquiv = "X-UA-Compatible";
meta.content = "IE=edge, IE=11, IE=10, IE=9";
document.getElementByTagName('head')[0].appendChild(meta);

But after changing this My IE browser is changed its default version to 7 from 11.

kindly let me know why it was changed.

2

There are 2 best solutions below

3
gvozd1989 On

You have a lost b letter in X-UA-Compatible. And you cannot set multiple versions in content.

0
Zhi Lv On

We could use JavaScript to add meta tag or modify the meta tag content, but, it will be generated after the page is loaded. So, if you use F12 developer tools to check, you can see that: the meta tag content value and the Browser Document mode are not matched.

More details information, please refer to the following screenshot:

enter image description here

So, in my opinion, I suggest you could directly add meta tag in the head. instead of via JavaScript.

<meta http-equiv="X-UA-Compatible" content="IE=9" />