Conditional Comments IE7 does not work

Asked

Viewed 112 times

2

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

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

Aqui viria outro *HTML* sem condicional
  • Here on IE7 I have installed worked normally.

  • which IE you are using? as you did the IF?

  • IE7 as I said, from what I understand you want a "ELSE" for parole?

  • this, if IE7 will appear what is in the conditional comment of another browser appears below which is not conditional

  • If I were religious I would pray that the spirituality felt sorry for your soul just because you have to support IE7 (MS is already in 11...)

1 answer

2


If I understand what you’re saying you want some sort of ELSE for the condition, 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 stated by the page https://msdn.microsoft.com/pt-br/library/hh801214(v=vs.85). aspx, nay 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 going over all of this and abandoning these kinds of hacks maybe even create something simpler that still meets the expected functionality and behave equally in several browsers, I know it depends on experience, but this is the opportunity to improve, because supporting two different things can bring you as many headaches as trying to create something simple that runs at all.

  • I did, instead of IE7 getting that <!-[if IE 7]> <p>You’re using Internet Explorer 7!</p> <! [endif]-> is picking up the other one here in the browser... also nothing appears in ie10, edge and Chrome

  • @Rafaelcastro do you happen to have some tag with X-UA-Compatible or accidentally activated the "compatibility mode" in the IE?

  • I am using edge emulation to test and am not using the X-UA-Compatible tag

  • @Rafaelcastro emulation may have some BUG my IE10 had this BUG I did the update on windowsupdate and solved. However I recommend reviewing the use of "Conditional Comments"

  • I’ll give you an update here and tag, thank you

  • @Rafaelcastro downloads Ietester: http://www.my-debugbar.com/wiki/IETester/HomePage to emulate IE6/7/8/9/10

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.