HTML IE条件语句:不适用于Chrome / Firefox

编程入门 行业动态 更新时间:2024-10-13 10:22:52
本文介绍了HTML IE条件语句:不适用于Chrome / Firefox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

在Chrome / Firefox中查看时,它错误地显示我是IE,我不是IE而不是我不是IE。 =jsfiddle/Hgx97/ =noreferrer> jsfiddle/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"

jsfiddle/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

本文发布于:2023-10-26 17:42:14,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:语句   不适用于   条件   HTML   Chrome

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!