获得 Javascript 版本
时间:2010-09-01 来源:liushan
最近看一个人的BLOG,发现这个文章,非常不错,引入来存档
<script type="text/javascript"> function getjsversion(){ var n = navigator; var u = n.userAgent; var apn = n.appName; var v = n.appVersion; var ie = v.indexOf('MSIE ') if(ie > 0){ apv = parseInt(i = v.substring(ie + 5)); if(apv > 3) { apv = parseFloat(i); } }else{ apv = parseFloat(v); } var isie = (apn == 'Microsoft Internet Explorer'); var ismac = (u.indexOf('Mac') >= 0); var javascriptVersion = "1.0"; if(String && String.prototype){ javascriptVersion = '1.1'; if(javascriptVersion.match){ javascriptVersion = '1.2'; var tm = new Date; if(tm.setUTCDate){ javascriptVersion = '1.3'; if(isie && ismac && apv >= 5) javascriptVersion = '1.4'; var pn = 0; if(pn.toPrecision){ javascriptVersion = '1.5'; a = new Array; if(a.forEach){ javascriptVersion = '1.6'; i = 0; o = new Object; tcf = new Function('o','var e,i=0;try{i=new Iterator(o)}catch(e){}return i'); i = tcf(o); if(i && i.next) { javascriptVersion = '1.7'; } } } } } } return javascriptVersion; } alert(getjsversion()); </script>
来源:http://www.phppan.com/2010/09/how-to-check-javascript-version/
相关阅读 更多 +