返回列表

IE浏览器版本检测

默认分类 2014/08/04 19:18

代码如下:

<b id="a"></b>
<script type="text/javascript">
<!--
var br;
     if (window.ActiveXObject && !window.XMLHttpRequest) {
    br = 'IE6';
}
else if (window.ActiveXObject &&  window.XMLHttpRequest && !document.querySelector) {
    br = 'IE7';
} 
else if (window.ActiveXObject &&  window.XMLHttpRequest &&  document.querySelector && !document.addEventListener) {
    br = 'IE8';
}
else if (window.ActiveXObject &&  window.XMLHttpRequest &&  document.querySelector &&  document.addEventListener) {
    br = '>= IE9';
}
document.getElementById('a').innerHTML = String(!window.querySelector);
//-->
</script>