码迷,mamicode.com
首页 > 编程语言 > 详细

如何用Javascript检测到所有的IE版本

时间:2017-03-24 17:50:00      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:on()   tom   user   ted   ret   use   ie版本   ring   idt   

如何用Javascript检测到所有的IE版本

function GetIEVersion() {

var sAgent = window.navigator.userAgent;

var Idx = sAgent.indexOf("MSIE");

?

// If IE, return version number.

if (Idx > 0)

return parseInt(sAgent.substring(Idx+ 5, sAgent.indexOf(".", Idx)));

?

// If IE 11 then look for Updated user agent string.

else if (!!navigator.userAgent.match(/Trident\/7\./))

return 11;

?

else

return 0; //It is not IE

}

?

if (GetIEVersion() > 0)

alert("This is IE " + GetIEVersion());

else

alert("This is not IE.");

?

?

如何用Javascript检测到所有的IE版本

标签:on()   tom   user   ted   ret   use   ie版本   ring   idt   

原文地址:http://www.cnblogs.com/time-is-life/p/6612401.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!