0
votes

How to force IE11 in html to use IE9 css styles.

I used this code

<script runat="server">
        private void Page_PreRender(object sender, EventArgs e)
        {
            var meta = new HtmlMeta();
            meta.Content = "IE=EmulateIE9";
            meta.HttpEquiv = "X-UA-Compatible";
            this.Page.Header.Controls.AddAt(0, meta);
        }
</script>

or

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

To get the same stylres when is internet explorer for all versions, taking ie9 as standard.

I am doing this code:

<!--[if IE]>
        <link rel="stylesheet" type="text/css" href="~/App_Themes/CocktailSite/master-interno-ie.css" media="screen" />
   <!--[else]>
        <link rel="stylesheet" type="text/css" href="~/App_Themes/CocktailSite/master-interno.css" media="screen" />
<![endif]-->

it is working when is IE9 and take master-interno-ie.css but in IE11 takes master-interno.

I was wahching all answer here and not worked in my case.

2
The if else is irrelevant since you're including the same file. - TheFrozenOne
i have X-UA-Compatible metatag over the <title> - David
doodlebunch how do i do it then? in two if? - David
I saw i had the same but bellow else is without -ie in the name of the file, error to type - David

2 Answers

0
votes

IE no longer evaluates conditional HTML comments.

As of Internet Explorer 10, conditional comments are no longer supported by standards mode. Use feature detection to provide effective fallback strategies for website features that aren't supported by the browser.

0
votes

I got it using jQuery.

between scripts and link i coded this:

function isIE() {
    var sAgent = window.navigator.userAgent;
    var Idx = sAgent.indexOf("MSIE");

    // If IE, return version number.
    if (Idx > 0) return true;    
    // If IE 11 then look for Updated user agent string.
    else if (!!navigator.userAgent.match(/Trident\/7\./)) return true;
    else return false; //It is not IE
}

After it I aded:

if (isIE()) {
    jQuery('head').append('<link rel="stylesheet" type="text/css"     href="~/App_Themes/CocktailSite/master-interno-ie.css" media="screen" />');
}     

it is working for my neededs.

TESTED FOR ALL IE versions, CHROME AND FIREFOX