获得当前浏览器JS的版本
2021-04-03 08:25
标签:microsoft mat bsp cat reac next || internet window 获得当前浏览器JS的版本 标签:microsoft mat bsp cat reac next || internet window 原文地址:https://www.cnblogs.com/luorende/p/12543494.html 1 获得当前浏览器JS的版本
2 function getjsversion(){
3 var n = navigator;
4 var u = n.userAgent;
5 var apn = n.appName;
6 var v = n.appVersion;
7 var ie = v.indexOf(‘MSIE ‘);
8 if (ie > 0){
9 apv = parseInt(i = v.substring(ie + 5));
10 if (apv > 3) {
11 apv = parseFloat(i);
12 }
13 } else {
14 apv = parseFloat(v);
15 }
16 var isie = (apn == ‘Microsoft Internet Explorer‘);
17 var ismac = (u.indexOf(‘Mac‘) >= 0);
18 var javascriptVersion = "1.0";
19 if (String && String.prototype) {
20 javascriptVersion = ‘1.1‘;
21 if (javascriptVersion.match) {
22 javascriptVersion = ‘1.2‘;
23 var tm = new Date;
24 if (tm.setUTCDate) {
25 javascriptVersion = ‘1.3‘;
26 if (isie && ismac && apv >= 5) javascriptVersion = ‘1.4‘;
27 var pn = 0;
28 if (pn.toPrecision) {
29 javascriptVersion = ‘1.5‘;
30 a = new Array;
31 if (a.forEach) {
32 javascriptVersion = ‘1.6‘;
33 i = 0;
34 o = new Object;
35 tcf = new Function(‘o‘, ‘var e,i=0;try{i=new Iterator(o)}catch(e){}return i‘);
36 i = tcf(o);
37 if (i && i.next) {
38 javascriptVersion = ‘1.7‘;
39 }
40 }
41 }
42 }
43 }
44 }
45 return javascriptVersion;
46 }
47
48
49 获取当前点击事件的Object对象
50 function getEvent() {
51 if (document.all) {
52 return window.event; //如果是ie
53 }
54 func = getEvent.caller;
55 while (func != null) {
56 var arg0 = func.arguments[0];
57 if (arg0) {
58 if ((arg0.constructor == Event || arg0.constructor == MouseEvent)
59 || (typeof (arg0) == "object" && arg0.preventDefault && arg0.stopPropagation)) {
60 return arg0;
61 }
62 }
63 func = func.caller;
64 }
65 return null;
66 };
67