我遇到了麻烦
<!--[if !IE]>
上班。 我不知道是否是因为我有这个在我的文档
<!doctype html>
<!--[if lt IE 7]> <html class="ie6 oldie"> <![endif]-->
<!--[if IE 7]> <html class="ie7 oldie"> <![endif]-->
<!--[if IE 8]> <html class="ie8 oldie"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="">
<!--<![endif]-->
当我添加
<!--[if !IE]><!-->
<link type="text/css" rel="stylesheet" href="/stylesheets/no-ie.css" />
<!--<![endif]-->
我由于某种原因,这是行不通的头。 但是,如果我添加
<!--[if !IE]><!-->
<style>
All my css in here
</style>
<!--<![endif]-->
实际的html页面(在头),它的工作原理。 有什么建议? 干杯
更新我的问题
好吧,当我删除<!-->
我只能在IE中这是工作的检查,但现在又回到FF无ie.css已应用于FF太。 所以我在加回<!-->
和删除/(并补充说,到主模板,以便将CMS不会增加回)和所有的工作早在FF但现在的样式表被应用到IE ! 所以,我想
<!--[if IE]>
<link type="text/css" rel="stylesheet" href="/stylesheets/no-ie.css">
<![endif]-->
和
<!--[if !IE]> -->
<link type="text/css" rel="stylesheet" href="/stylesheets/no-ie.css">
<!-- <![endif]-->
而没有工作。 基本上我试图让这个页面正常工作http://css-tricks.com/examples/ResponsiveTables/responsive.php但移动到CSS样式表。 当然这一定是简单的。 我在想什么? 我宁可不使用JQuery,如果我没有。 干杯
Answer 1:
<!--[if !IE]><!--><script src="zepto.min.js"></script><!--<![endif]-->
<!--[if IE]><script src="jquery-1.7.2.min.js"></script><![endif]-->
注意:这些条件注释不再IE 10日起支持 。
Answer 2:
比IE等浏览器处理的条件语句作为注释,因为他们是封闭的注释标签内。
<!--[if IE]>
Non-IE browsers ignore this
<![endif]-->
但是,当你的目标浏览器是不是IE,你必须使用2个评论,一前一后的代码。 IE会忽略它们之间的代码,而其他浏览器将其当作普通的代码。 因此用于靶向非IE浏览器的语法是:
<!--[if !IE]-->
IE ignores this
<!--[endif]-->
注意:这些条件注释不再IE 10日起支持 。
Answer 3:
更新如果有人仍然达到这个页面,不知道为什么,即针对不工作。 IE 10及以后不再支持有条件的意见。 从MS官方网站:
有条件的意见表示支持已在Internet Explorer 10的标准和怪癖模式,以提高互操作性和符合HTML5被删除。
请在这里看到更多的细节: http://msdn.microsoft.com/en-us/library/ie/hh801214(v=vs.85).aspx
如果你迫切需要的目标,即,您可以使用此jQuery代码到即添加类,然后使用.IE类在你的CSS的目标,即浏览器。
if ($.browser.msie) {
$("html").addClass("ie");
}
更新:$ .browser的jQuery 1.9后不可用。 如果升级到jQuery的1.9以上或者你已经在使用它,你可以包括jQuery的jQuery的后迁移脚本,以便它添加缺少的部分: jQuery的迁移插件
:另外,请检查该线程可能的解决方法更新后browser.msie错误的jQuery 1.9.1
Answer 4:
我使用的,它的工作原理:
<!--[if !IE]><!--> if it is not IE <!--<![endif]-->
Answer 5:
对于下级-透露有条件的“意见”微软推荐的语法是这样的:
<![if !IE]>
<link type="text/css" rel="stylesheet" href="/stylesheets/no-ie.css" />
<![endif]>
这些都是不评论,但他们正常工作。
Answer 6:
你需要把一个空间的<!-- [if !IE] -->
我的完整的CSS块进入如下,由于IE8是可怕与媒体查询
<!-- IE 8 or below -->
<!--[if lt IE 9]>
<link rel="stylesheet" type="text/css" href="/Resources/css/master1300.css" />
<![endif]-->
<!-- IE 9 or above -->
<!--[if gte IE 9]>
<link rel="stylesheet" type="text/css" media="(max-width: 100000px) and (min-width:481px)"
href="/Resources/css/master1300.css" />
<link rel="stylesheet" type="text/css" media="(max-width: 480px)"
href="/Resources/css/master480.css" />
<![endif]-->
<!-- Not IE -->
<!-- [if !IE] -->
<link rel="stylesheet" type="text/css" media="(max-width: 100000px) and (min-width:481px)"
href="/Resources/css/master1300.css" />
<link rel="stylesheet" type="text/css" media="(max-width: 480px)"
href="/Resources/css/master480.css" />
<!-- [endif] -->
Answer 7:
用于靶向IE用户:
<!--[if IE]>
Place Content here for Users of Internet Explorer.
<![endif]-->
对于瞄准所有其他:
<![if !IE]>
Place Content here for Users of all other Browsers.
<![endif]>
该条件注释只能由Internet Explorer进行检测,其他所有浏览器线程它作为正常的评论。
要针对IE 6,7等。你必须使用“大于等于”或“小比(等于)”中的if语句。 像这样。
大于或等于:
<!--[if gte IE 7]>
Place Content here for Users of Internet Explorer 7 or above.
<![endif]-->
小比:
<!--[if lt IE 6]>
Place Content here for Users of Internet Explorer 5 or lower.
<![endif]-->
来源:mediacollege.com
Answer 8:
首先,正确的语法是:
<!--[if IE 6]>
<link type="text/css" rel="stylesheet" href="/stylesheets/ie6.css" />
<![endif]-->
试试这个职位: http://www.quirksmode.org/css/condcom.html和http://css-tricks.com/how-to-create-an-ie-only-stylesheet/
另一件事,你可以这样做:
检查浏览器使用jQuery:
if($.browser.msie){ // do something... }
在这种情况下,您可以更改CSS规则的一些元素或添加新的CSS链接参考:
阅读: http://rickardnilsson.net/post/2008/08/02/Applying-stylesheets-dynamically-with-jQuery.aspx
Answer 9:
这是直到IE9
<!--[if IE ]>
<style> .someclass{
text-align: center;
background: #00ADEF;
color: #fff;
visibility:hidden; // in case of hiding
}
#someotherclass{
display: block !important;
visibility:visible; // in case of visible
}
</style>
这是IE9后
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {enter your CSS here}
Answer 10:
对于IE浏览器:
<!--[if IE]>
<meta http-equiv="Content-Type" content="text/html; charset=Unicode">
<![endif]-->
对于所有非IE浏览器:
<![if !IE]>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<![endif]>
对于所有IE大于8或所有非IE浏览器:
<!--[if (gt IE 8)|!(IE)]><!--><script src="/_JS/library/jquery-2.1.1.min.js"></script><!--<![endif]-->
Answer 11:
条件注释是一个注释以<!--[if IE]>
这不能由除了IE任何浏览器读取。
从2011年由微软在那个时候宣布有条件评论并不支持起始形式IE 10 https://msdn.microsoft.com/en-us/library/hh801214(v=vs.85).aspx
使用条件注释唯一的选择是请求IE运行您的网站IE 9支持有条件的意见。
你可以写自己的CSS和/或JS文件,即只有和其他浏览器将不会加载或执行它。
此代码段示出了如何使IE 10或11运行IE-only.css和IE-only.js其包含自定义码来解决IE的兼容性问题。
<html>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">
<!--[if IE]>
<meta http-equiv="Content-Type" content="text/html; charset=Unicode">
<link rel="stylesheet" type="text/css" href='/css/ie-only.css' />
<script src="/js/ie-only.js"></script>
<![endif]-->
</html>
Answer 12:
这对我的作品跨越超过6版本更高的所有浏览器(IE 7,8,9,10,等等,三价铬到它现在是什么,以及FF版本3到它现在是什么):
//test if running in IE or not
function isIE () {
var myNav = navigator.userAgent.toLowerCase();
return (myNav.indexOf('msie') != -1 || myNav.indexOf('trident') != -1) ? true : false;
}
Answer 13:
如果您正在使用IE 10或以上的工作,如在提到http://tanalin.com/en/articles/ie-version-js/条件注释不再支持。 你可能是指https://gist.github.com/jasongaylord/5733469作为一种替代方法,它三叉戟版本从navigator.userAgent的检查为好。 这也验证了的情况下,浏览器在兼容模式下工作。
Answer 14:
我使用这个JavaScript来检测IE浏览器
if (
navigator.appVersion.toUpperCase().indexOf("MSIE") != -1 ||
navigator.appVersion.toUpperCase().indexOf("TRIDENT") != -1 ||
navigator.appVersion.toUpperCase().indexOf("EDGE") != -1
)
{
$("#ie-warning").css("display", "block");
}
Answer 15:
谢谢Fernando68,我用这个:
function isIE () {
var myNav = navigator.userAgent.toLowerCase();
return (myNav.indexOf('msie') != -1 || myNav.indexOf('trident') != -1) ? true : false;
}
if(isIE()){
$.getScript('js/script.min.js', function() {
alert('Load was performed.');
});
}
Answer 16:
我得到这个代码工作在我的浏览器:
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
请注意此代码:HTML5希夫和Respond.js IE8支持HTML5元素和媒体查询
文章来源:
私信