我有一个只在mozilla和chrome上运行的jquery插件,并且不会在IE中运行< 10个版本,所以我必须使用备用插件,所以我如何运行这个脚本浏览器专门我尝试了这个,但没有工作。
<![if gte IE 8]>
<script type="text/javascript">
alert("IE 8");
</script>
<p>You're using a recent version of Internet Explorer.</p>
<![endif]>
<![if lt IE 7]>
<script type="text/javascript">
alert("IE 7");
</script>
<![endif]>
<![if !IE]>
<script type="text/javascript">
alert("IE 7");
</script>
<![endif]>
答案 0 :(得分:0)
<script type="text/javascript">
//userAgent in IE7 WinXP returns: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)
//userAgent in IE11 Win7 returns: Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko
if (navigator.userAgent.indexOf('MSIE') != -1)
var detectIEregexp = /MSIE (\d+\.\d+);/ //test for MSIE x.x
else // if no "MSIE" string in userAgent
var detectIEregexp = /Trident.*rv[ :]*(\d+\.\d+)/ //test for rv:x.x or rv x.x where Trident string exists
if (detectIEregexp.test(navigator.userAgent)){ //if some form of IE
var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
if (ieversion>=1){
alert("ie")
}
}
else{
alert ("other brower");
}
答案 1 :(得分:-1)
你的代码错了,请点击这里
<!--[if IE]>
According to the conditional comment this is IE<br />
<![endif]-->
<!--[if IE 6]>
According to the conditional comment this is IE 6<br />
<![endif]-->
<!--[if IE 7]>
According to the conditional comment this is IE 7<br />
<![endif]-->
<!--[if IE 8]>
According to the conditional comment this is IE 8<br />
<![endif]-->
<!--[if IE 9]>
According to the conditional comment this is IE 9<br />
<![endif]-->
<!--[if gte IE 8]>
According to the conditional comment this is IE 8 or higher<br />
<![endif]-->
<!--[if lt IE 9]>
According to the conditional comment this is IE lower than 9<br />
<![endif]-->
<!--[if lte IE 7]>
According to the conditional comment this is IE lower or equal to 7<br />
<![endif]-->
<!--[if gt IE 6]>
According to the conditional comment this is IE greater than 6<br />
<![endif]-->
<!--[if !IE]> -->
According to the conditional comment this is not IE 5-9<br />
<!-- <![endif]-->