Conditional Comments IE7 does not work

2

I have an HTML code, one with a conditional to appear only in IE7 and below I put another unconditional code to appear in IE8 up and in other browsers, but when I open IE7 the browser is pulling the other code without the conditional. Does anyone know a solution?

<!--[if IE 7]> 
HTML todo
<![endif]-->

Aqui viria outro *HTML* sem condicional
    
asked by anonymous 11.05.2017 / 17:13

1 answer

2

If I understood what you said you want a kind of ELSE for the condition, you could do this if !(IE 7) , for example:

<!--[if IE 7]>
<p>Você esta usando Internet Explorer 7!</p>
<![endif]-->

<!--[if !(IE 7)]>
<p>Você esta usando outro navegador!</p>
<![endif]-->

However I recommend rethinking the use of this because conditional comments do not work in modern browsers as said by the link , no there is more support from Internet Explorer 10, however it is possible to make it work by emulating IE9 for example, just add this:

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

So I recommend to review all this and abandon these types of hacks maybe even create something simpler that still meets the expected features and behaves equally in different browsers, I know it depends on experience , but this is the opportunity to improve because giving support for two different things can bring you as many headaches as trying to create something simple that runs at all.

    
11.05.2017 / 17:55