2

It is very simple HTML page which I am trying to render on IE 11 but somehow never takes the IE specific css file.

I am attaching my code here.

 <!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="images/favicon.ico">

    <title>Demo</title>

    <!-- Custom styles for this template -->
    <link href="css/style.css" rel="stylesheet">
    <!--[if IE]>
        <link rel="stylesheet" type="text/css" href="css/all-ie-only.css" />
    <![endif]-->

  </head>
  <body class="subpage">

  </body>
</html>

And my css contains :

style.css

body{background:blue;}

all-ie-only.css

body{background:red;}

Note : I already referred and tried solution from similar question like below with no luck.

ie only stylesheet not working, code included

Solution I tried with no luck :

<script>
/*@cc_on

  @if (@_jscript_version == 11)
    document.write("You are using IE11 with an older document mode");
  @elif (@_jscript_version == 10)
    document.write("You are using IE10");
  @elif (@_jscript_version == 9)
    document.write("You are using IE9");
  @elif (@_jscript_version == 5.8)
    document.write("You are using IE8");
  @elif (@_jscript_version == 5.7 && window.XMLHttpRequest)
    document.write("You are using IE7");
  @elif (@_jscript_version == 5.6 || (@_jscript_version == 5.7 && !window.XMLHttpRequest))
    document.write("You are using IE6");
  @elif (@_jscript_version == 5.5)
    document.write("You are using IE5.5");
  @elif (@_jscript_version < 5.5)
    document.write("You are using a version older than IE5.5");
  @else
    document.write("You are using an unknown version of IE");
  @end

@*/
</script>

What I have tried with is as suggested here : https://en.wikipedia.org/wiki/Conditional_comment

It seems, it never gets into if conditions specifying "@_jscript_version". Any help futher appreciated.

Hiral Vadodaria
  • 19,158
  • 5
  • 39
  • 56
  • As marked this question duplicated with "https://stackoverflow.com/questions/27470022/if-conditional-statement-not-working-with-ie-11" link, I couldn't find solution to my problem from this. It has some confusing answer which lead me nowhere and I am still stuck. – Hiral Vadodaria Sep 27 '18 at 06:42
  • check the link in the accepted answer in the duplicate question. It clearly states that IE10+ no longer has conditional statement support. All IE sees now is a commented block of HTML, so it will not parse it. You will have to use a different way to get things done, also explained in the other question. – Oldskool Sep 27 '18 at 11:36
  • I clearly understood that the IE10+ no longer supports conditional statement but I also specified that no solution was found for my issue. I already checked around and tried various solution. But nothing works. Check my comment on first answer of this question. – Hiral Vadodaria Sep 27 '18 at 11:53
  • If you're getting stuck on other solutions, please edit the question with the specific problems you're having with those solutions. As it currently stands, this question is still a duplicate of existing questions. – Oldskool Sep 27 '18 at 12:05

1 Answers1

4

IE10 and IE11 do not support conditional comments.

Conditional comments are no longer supported in IE10 and IE11.

https://en.wikipedia.org/wiki/Conditional_comment

connexo
  • 53,704
  • 14
  • 91
  • 128
  • Thanks for the reply. I tried mentioned code on this page but it doesn't work for me somehow. It seems, it never gets into if conditions specifying "@_jscript_version". Any help can you offer further? – Hiral Vadodaria Sep 27 '18 at 06:39