我如何制作一个";否则";在IE HTML条件中
How do I make an "else" in an IE HTML conditional?
<!--[if lt IE 9]>
This is less then IE9
ELSE
this is all browsers: firefox, chrome, etc.
<![endif]-->
如何在HTML中做到这一点?我想做一个"其他"。。。
您不是在寻找else,而是在寻找<![if !IE]> <something or other> <!--[endif]>
(请注意,这不是注释(。
<!--[if IE]>
You're using IE!
<![endif]-->
<![if !IE]>
You're using something else!
<![endif]>
你可以在这里找到关于条件注释的文档。
我使用以下方法在IE9或更新版本以及所有其他浏览器中加载资源
<!--[if gte IE 9]><!-->
//your style or script
<!--<![endif]-->
这令人难以置信。查看打开和关闭if语句部分是否在注释中(因此,它对其他浏览器不可见(,但对IE可见。
问题的解决方案是(注意<!-- -->
的使用(:
<!--[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]-->
条件注释既可以在脚本中也可以在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]-->
@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]-->
<!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。
感谢您按此特定顺序提供这些字母/符号!
相关文章:
- RegEx删除空属性?例如,如果(class=“”||class=“”)移除;否则就下课
- 铬:“;未捕获的语法错误:意外的标记:"
- 可以设置“;文件名"发生错误时显示的内联脚本标记的
- JS表单提交"无法使用Chrome数据保护程序加载此页面.尝试重新加载页面.调试信息:POST CISmtuK
- 检测电话窃听,即:<a href="电话:xxx">在UIWebview上
- 使用“+="操作人员
- //而不是在src=“”上使用http://"属性
- "未捕获的语法错误:意外的标记}"
- 可以<脚本类型=“;text/javascript”>window.location=“/"</
- "实例范围”;TypeScript类的getter/setter
- Javascript复选框函数:;缺少:在属性id之后"
- "“;变量未引用正确的对象
- "日期“;AJAX请求返回的类型值未定义
- 得到"TypeError:无法读取属性'filename'未定义的“;调用“npm start
- Soundcloud api"未捕获的类型错误:无法读取属性'uri'“未定义”;
- "工具提示"jQuery插件坏了
- "锻造;React中的表达式
- 图像可以从源<img src=""/>.TEXT可以在没有javascript的情况下从外部
- 如何提取“;href"最近列表项中的属性值
- 浏览器跳过“;如果“"否则如果“;,直接转到“;否则”;陈述