1 varBrowservision = {2Get:function () {3 ///<summary>4 ///Get Browser name and version5 ///</summary>6 ///<returns type= "String"/>7 varAgent =navigator.useragent;8 varBrowser = "";9 varVersion = "";Ten if(/msie/. Test (agent)) { OneBrowser = "IE"; A varReg_match = Agent.match (/msie[\w\w]+;/) [0]; -Reg_match = Reg_match.split (";") [0]; -Version = Reg_match.split ("") [1]; the } - Else if(/trident/.test (agent) &&/rv:11.0/. Test (agent)) { -Browser = "IE"; -Version = "11.0" + } - Else if(/safari/.test (agent) &&! (/chrome/.test (agent)) &&! (/edge/. Test (agent)) { + varReg_match = Agent.match (/safari\/[\w\w]+$/) [0]; ABrowser = "Safari"; atVersion = Reg_match.split ("/") [1]; - } - Else if(/safari/.test &&/chrome/.test (agent) &&! (/edge/. Test (agent)) { - varReg_match = Agent.match (/chrome\/[\w\w]+\s/) [0]; -Browser = "Chrome"; -Version = Reg_match.split ("/") [1]; in } - Else if(/safari/.test (agent) &&/edge/. Test (agent)) { to varReg_match = Agent.match (/edge\/[\w\w]+$/) [0]; +Browser = "Edge"; -Version = Reg_match.split ("/") [1]; the } * Else { $Browser = "Unknow";Panax NotoginsengVersion = "0"; - } the returnBrowser + "," +version; + }, AIsie:function () { the ///<summary> + ///Determine if IE is - ///& #10;--Returns 1, otherwise returns 0 $ ///</summary> $ ///<returns type= "int"/> - varAgent =navigator.useragent; - if(/msie/.test (agent) | | (/trident/.test (agent) &&/rv:11.0/. Test (agent)) { the return1; - }Wuyi Else { the return0; - } Wu }, -Ielowerthan:function(version) { About ///<summary> $ ///Determine if IE is less than the specified version - ///& #10;--yes return 1 - ///& #10;--not less than the specified version returns 0; not IE returns 0; wrong parameter returns 0 - ///</summary> A ///<param type= "float" name= "version" > + ///Version Number the ///</param> - ///<returns type= "int"/> $ if(Version! = undefined &&!IsNaN (version)) { the varBrowser =browservision.get (); the if(/ie/. Test (browser)) { the varBrow_ver = parsefloat (Browser.split (",") [1]); the varVersion =parsefloat (version); - if(Brow_ver <version) { in return1; the } the Else { About return0; the } the } the Else { + return0; - } the }Bayi Else { the return0; the } - } -}
View Code
These are some of the logic of the browser version judgment, and then we just need to invoke the IF (Browservision.ielowerthan (8)) {
Operation of the lower version browser. I used two brothers. Div contains normal content and hint content, with the effect of the DIV's explicit hiding
$ (". Js-content"). Hide ();
$ (". Js-update"). Show ();
}
To determine the version of the browser, there is a low version prompt