Knaģis
Knaģis

Reputation: 21485

Conditionally load scripts in IE11 that runs in IE8 compatibility mode

My application currently dynamically includes jQuery 1.11 version for IE7 and IE8 but jQuery 2 for IE9+/Chrome/FF using conditional comments.

<!--[if lt IE 9]>
@Scripts.Render("~/bundles/jquery-legacy")
<![endif]-->
<!--[if (gte IE 9) | (!IE)]><!-->
@Scripts.Render("~/bundles/jquery")
<!--<![endif]-->

This runs fine in all IE versions up to and including 10, including all compatibility modes. Unfortunately IE11 ignores conditional comments even when it is running in compatibility mode. Normally this would not be a problem since <meta http-equiv="X-UA-Compatible" content="IE=edge"> forces the Edge mode. Unfortunately there is one exception - if the Active Directory policy specifies some Enterprise compatibility mode, it overrides all webpage settings and forces the browser in IE8 mode.

Rewriting the script loading to use something like require.js is not really an option for the existing application.

What am I missing that could help me to either load the scripts conditionally or force the browser to be in edge mode even though AD says otherwise?

Upvotes: 0

Views: 1673

Answers (1)

Zoom
Zoom

Reputation: 401

Enterprise mode runs with a document mode of IE8 but it appears not to be in that browser mode so it skips the conditional comments like the regular IE11.

I have managed to change that mode with the following meta tag.

<meta http-equiv="X-UA-Compatible" content="IE=8,IE=edge" />

Enterprise mode only reads the IE8 compatibility. Other versions such as IE9 and later read and support the edge mode which gives you the latest features of those browsers.

Upvotes: 1

Related Questions