有没有办法检测IE7?
我的代码在IE8中没有问题,但是在IE7中出现了问题。
因此,我的想法是在javascript检测到浏览器是IE7时,使用jquery添加一个类。
我想要从...更改
<div id="system">
至
<div id="system" class="ie7">
提前致谢。
有没有办法检测IE7?
我的代码在IE8中没有问题,但是在IE7中出现了问题。
因此,我的想法是在javascript检测到浏览器是IE7时,使用jquery添加一个类。
我想要从...更改
<div id="system">
至
<div id="system" class="ie7">
提前致谢。
如果你确实想用JavaScript解决这个问题,你可能需要像这样检查版本:
if (navigator.appVersion.indexOf("MSIE 7.") != -1)
$('#system').addClass('ie7');
<!--[if IE 7]>
<script type="text/javascript">
$(document).ready(function() {
$('#system').addClass('ie7');
});
</script>
<![endif]-->
只需使用HTML即可:
CSS
.ie7{
padding: 0;
color: red;
}
html
<!--[if IE 7 ]> <div id="system" class="ie7"> <![endif]-->
<!--[if (gt IE 7)|!(IE)]><!--> <div id="system"> <!--<![endif]-->
</div>
如果在Internet Explorer 7中执行此代码,将创建具有ie7
类的div
。所有其他浏览器和IE > 7都将创建没有该类的div。
<body class="ie7">
,然后使用CSS包含选择器body.ie7 #system
,以避免在整个文档中重复条件注释。 - bobince要检测ie7,只需使用以下代码:
if($.browser.msie && parseFloat($.browser.version) < 8){
//do other stuff
return;
}
要按照您的需求操作它,只需要:
if($.browser.msie && parseFloat($.browser.version) < 8){
$('#system').addClass('ie7');
}
.browser
。 - Brad试试这个:
<!--[if IE 7]>
<script type="text/javascript">
$('#system').addClass('ie7');
</script>
<![endif]-->
<!--[if IE 7 ]>
为真。<!--[if IE 7]>
<script type="text/javascript">
try
{
if(document.documentMode!=8){
//Your code comes here
}
}
catch(exception){
}
</script>
<!--<![endif]-->