Get the current version of the browser JS

 

 

1  to obtain the current version of the browser 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. the indexOf ( 'MSIE' );
 . 8      IF (IE> 0 ) {
 . 9          APV = the parseInt (I = v.substring (IE +. 5 ));
 10          IF (APV>. 3 ) {
 . 11              APV = parseFloat (I);
 12 is          }
 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 Get current click event Object object
 50  function getEvent () {
 51 is      IF {(the document.all)
 52 is          return the window.event; // if IE 
53 is      }
 54 is      FUNC = getEvent.caller;
 55      the while (FUNC =! Null ) {
 56 is          var the arg0 func.arguments = [0 ];
 57 is          IF (the arg0) {
 58              IF ((|| arg0.constructor the Event == == arg0.constructor the MouseEvent)
 59 || ( typeof (the arg0) == "Object" && && arg0.preventDefault arg0.stopPropagation)) {
60                 return arg0;
61             }
62         }
63         func = func.caller;
64     }
65     return null;
66 };
67   

 

Guess you like

Origin www.cnblogs.com/luorende/p/12543494.html