【发布时间】:2011-10-08 04:44:12
【问题描述】:
<!--[if lt IE 9]>
This is less then IE9
ELSE
this is all browsers: firefox, chrome, etc.
<![endif]-->
如何在我的 HTML 中执行此操作?我想做一个“其他”...
【问题讨论】:
标签: javascript html css internet-explorer-9
<!--[if lt IE 9]>
This is less then IE9
ELSE
this is all browsers: firefox, chrome, etc.
<![endif]-->
如何在我的 HTML 中执行此操作?我想做一个“其他”...
【问题讨论】:
标签: javascript html css internet-explorer-9
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">
</head>
<!--[if IE]>
<body style="margin: 38px 0 0 0;">
<![endif]-->
<!--[if !IE]>
<body>
<![endif]-->
-Content-
</body>
</html>
经过数小时的搜索,这对我有用。我需要一个弹出横幅的头部空间,IE 不想动画。它应该在几秒钟后隐藏起来。使用它,我可以将整个页面向下移动,但只能在 IE 中,这正是我所需要的!
目前只针对还在使用 IE 的人,我自己更喜欢 FireFox 或 Chrome。
感谢您按特定顺序提供这些字母/符号!
【讨论】:
@cwallenpoole 接受的答案破坏了标记,使 HTML 无效,并破坏了 Visual Studio 的语法突出显示。
保持清洁的方法如下:
<!--[if IE]>
You're using IE!
<![endif]-->
<!--[if !IE]><!-->
You're not using IE. See, even SO highlights this correctly.
<!--<![endif]-->
【讨论】:
你的问题的解决方法是(注意使用<!-- -->):
<!--[if lt IE 9]>
This is less then IE9
<![endif]-->
<!--[if gt IE 8]> <!-- -->
this is all browsers: IE9 or higher, firefox, chrome, etc.
<!-- <![endif]-->
【讨论】:
我在IE9或更高版本以及所有其他浏览器中使用以下加载资源
<!--[if gte IE 9]><!-->
//your style or script
<!--<![endif]-->
这很难相信。查看 if 语句部分的开头和结尾部分在 cmets 内(因此,它对其他浏览器不可见)但对 IE 可见。
【讨论】:
<!--[if lte IE 8]> ... ... <![endif]-->之前这应该涵盖使用CSS媒体查询时要检查的所有条件。
<!,“-->”将出现在 IE 9 的页面上,因此您确实希望包含那个。
<!--[if IE]> 在 IE7 兼容模式下不起作用。如果您不幸支持 IE6,请使用此答案中的语法使其工作:-|
条件 cmets 可以在脚本中也可以在 html 中-
/*@cc_on
@if(@_jscript_version> 5.5){
navigator.IEmod= document.documentMode? document.documentMode:
window.XMLHttpRequest? 7: 6;
}
@else{
alert('your '+navigator.appName+' is older than dirt.');
}
@end
@*/
【讨论】:
您无需填写else。 暗示。所以
// put your other stylesheets here
<!--[if lt IE 9]>
//put your stylesheet here for less than ie9
<![endif]-->
【讨论】:
您不是在寻找其他人,而是在寻找 <![if !IE]> <something or other> <!--[endif]>(请注意,这不是评论)。
<!--[if IE]>
You're using IE!
<![endif]-->
<![if !IE]>
You're using something else!
<![endif]>
您可以找到有关条件 cmets here 的文档。
【讨论】:
<![if !(IE 7)]>
if IE 将不在 IE 10 中工作......请参阅下面的 KhanSharp 答案以获得现代解决方案。
<!--[if gt IE 8]> <!-- --> Here is some code for anything but IE 8 and below. <!-- <![endif]-->。见:stackoverflow.com/a/10159787/903186