0

In my site I have an IE HTML conditional like this :

<!--[if lte IE 8]>
      <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
      <![endif]-->

..... the rest code of the html page

when I run my web page in IE 8 I only want the code inside the condition to be displayed and I dont want to display the rest of the web page.

How can I do that ?

Edit 1

When I tried this :

<!--[if gt IE 8]>

...My code

<![endif]-->

It didnt work when I run my web page on firefox or chrome.

Community
  • 1
  • 1
Renaud is Not Bill Gates
  • 1,684
  • 34
  • 105
  • 191
  • check this answer http://stackoverflow.com/a/25045631/1398867 – Venugopal Dec 25 '15 at 20:44
  • Possible duplicate of [Html detect IE8 and lower or any other browser](http://stackoverflow.com/questions/25045565/html-detect-ie8-and-lower-or-any-other-browser) – Venugopal Dec 25 '15 at 20:47
  • @Venugopal I already tried those solution before I wrote this question they didnt work for me the content inside the second IF is not displayed anymore – Renaud is Not Bill Gates Dec 25 '15 at 22:04

2 Answers2

0

I would prefer to use PHP for this action:

<?php if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') && preg_match('/(?i)MSIE [6-8]/',$_SERVER['HTTP_USER_AGENT'])) { ?>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<?php } ?>

A faked or filtered HTTP_USER_AGENT on IE is imho very unlikely.

HQ5
  • 81
  • 10
0

Adding hyphens (--) makes it a Downlevel-hidden conditional comments which makes downlevel browsers (any browser or browser version that doesn't support conditional comments) ignore the HTML content inside the comment block - if the statement is true

Use the Downlevel-revealed conditional comments instead by removing the hyphens:

<![if gt IE 8]>

...Your content

<![endif]>

https://msdn.microsoft.com/en-us/library/ms537512%28v=vs.85%29.aspx#dlrevealed

securecodeninja
  • 2,497
  • 3
  • 16
  • 22