HTML IE条件语句:不适用于Chrome / Firefox [英] HTML IE conditional statement: Not working with Chrome/Firefox

查看:189
本文介绍了HTML IE条件语句:不适用于Chrome / Firefox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <! -  [if(IE)]><< ;  - >我是IE<! - <![endif]  - > 
<! - [if!(IE)]><! - >我不是,即<! - <![endif] - >

在IE中查看时,它正确地显示我是IE



在Chrome / Firefox中查看时,它错误地显示我是IE,我不是IE而不是我不是IE。 =http://jsfiddle.net/Hgx97/ =noreferrer> http://jsfiddle.net/Hgx97/

解决方案

您在第一行中错误地终止了IE条件注释,所以其他浏览器将会看到分隔符之间的内容(您还可以看到第一行的文本如何突出显示为黑色,不是你想要的):

 <! -  [if(IE)]>我是IE<![endif]  - > 
<! - [if!(IE)]><! - >我不是,即<! - <![endif] - >

第二行是正确的,因为您想将内容展示给非IE浏览器。



更新小提琴


I have the following in my html document.

<!--[if (IE)]><!-->  i am IE <!--<![endif]-->
<!--[if !(IE)]><!--> i am not ie <!--<![endif]-->

When viewed in IE it properly says "i am IE"

When viewed in Chrome/Firefox it incorrectly says "i am IE i am not ie" instead of "i am not IE"

http://jsfiddle.net/Hgx97/

解决方案

You're incorrectly terminating the IE conditional comments on the first line, so other browsers will see the content between the delimiters (you can also see how the text is highlighted black on the first line, which is not what you want):

<!--[if (IE)]>       i am IE <![endif]-->
<!--[if !(IE)]><!--> i am not ie <!--<![endif]-->

The second line is correct since you want to show that content to non-IE browsers.

Updated fiddle

这篇关于HTML IE条件语句:不适用于Chrome / Firefox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆