<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>js判断浏览器版本及版本号</title><meta name="keywords" content="js 浏览器 版本 ie7 ie8 firefox2 firefox3" /><meta name="description" content="js判断浏览器版本及版本号,本代码支持最新的ie7,ie8,firefox2,firefox3的判断" /><meta name="author" content="北极星 | www.okajax.com" /><meta name="Copyright" content="Copyright (c) 2008-2010 okajax.com" /><script>
window["MzBrowser"]={};(function(){if(MzBrowser.platform) return;var ua = window.navigator.userAgent;MzBrowser.platform = window.navigator.platform;
MzBrowser.firefox = ua.indexOf("Firefox")>0;MzBrowser.opera = typeof(window.opera)=="object";MzBrowser.ie = !MzBrowser.opera && ua.indexOf("MSIE")>0;MzBrowser.mozilla = window.navigator.product == "Gecko";MzBrowser.netscape= window.navigator.vendor=="Netscape";MzBrowser.safari= ua.indexOf("Safari")>-1;
if(MzBrowser.firefox) var re = /Firefox(\s|\/)(\d+(\.\d+)?)/;else if(MzBrowser.ie) var re = /MSIE( )(\d+(\.\d+)?)/;else if(MzBrowser.opera) var re = /Opera(\s|\/)(\d+(\.\d+)?)/;else if(MzBrowser.netscape) var re = /Netscape(\s|\/)(\d+(\.\d+)?)/;else if(MzBrowser.safari) var re = /Version(\/)(\d+(\.\d+)?)/;else if(MzBrowser.mozilla) var re = /rv(\:)(\d+(\.\d+)?)/;
if("undefined"!=typeof(re)&&re.test(ua))MzBrowser.version = parseFloat(RegExp.$2);})();
function aa(){if(MzBrowser.ie){alert('ie');}if(MzBrowser.firefox){alert('firefox');}alert(MzBrowser.version);}aa();
</script></head>
<body></body></html>
JS 判断浏览器版本号
最新推荐文章于 2022-10-07 16:58:08 发布