Today, there is another hard-hit issue: how to determine the browser version through js. When I was a beginner, I tried to determine my own writing method. Later, I used a lot of jquery libraries and so on. I forgot about this. I remember when I read ibw code, I found a piece of related code, however, it has been in the draft box and has not been published. Show, show, and try again next time:
[Javascript]
_ T. Browser = function (sUA) {// IBW. Tool. Browser
Var win = window,
C = function (r ){
Return r. test (sUA );
},
IsIE =! + '\ V1 ',
IsTrident = isIE | !! Win. XDomainRequest,
IsWebkit =! IsTrident &&! Navigator. taintEnabled;
Return {
// Browser sniffing
IsIE: isIE,
IsIE6: isIE &&(! Win. XMLHttpRequest | !! Win. XMLHttpRequest. constructor ),
IsIE7: isIE &&!! Win. XMLHttpRequest &&! Win. XMLHttpRequest. constructor &&! Win. XDomainRequest,
IsIE8: isIE &&!! Win. XDomainRequest,
IsIE9 :! IsIE &&!! Win. XDomainRequest,
IsMaxthon :! Win. opera &&!! Win. external & typeof external. max_version! = 'Undefined', // an exception is thrown when opera reads external. external is null.
IsTT: c (/; TencentTraveler /),
Is360: c (/; 360 /),
IsSogou: c (/; SE \ d \./),
// Rendering engine sniffing.
IsWebkit: isWebkit, // safari chrome KHTML rendering engine .!! + '\ V1' prevents ie 6 from reporting errors
IsGecko :!! Document. getBoxObjectFor | win. policinnerscreenx! = Null, // firefox Rendering Engine
IsTrident: isTrident, // ie Rendering Engine
IsPresto :!! Win. opera, // opera Rendering Engine
// Extended sniffing
// Determine whether it is a high-speed sougou Browser
IsFastModeSogou: isWebkit &&!! Win. external & win. external. propertyIsEnumerable ('startpagecall '),
// Determine whether it is a high-speed sougou browser and need to trigger reflow (sougou2.0 fastMode) in flash mode)
IsFastModeSogouNeedReflow: isWebkit &&!! Win. external & win. external. propertyIsEnumerable ('startpagecall ')&&! ('Localdb' in external ),
// Determine whether it is a high-speed QQ5 Browser
IsFastModeQQ: isWebkit & win. external & 'webcorver 'in external,
// Determine whether iframe is supported to fix the flash div bug
IsIframeOnFlash: isTrident | function () {for (var o in {,}) return o = '0'; return '_'} () | (win. export innerscreenx = null &&!! Document. getBoxObjectFor)
};
} (Win. navigator. userAgent );
_ T. Browser = function (sUA) {// IBW. Tool. Browser
Var win = window,
C = function (r ){
Return r. test (sUA );
},
IsIE =! + '\ V1 ',
IsTrident = isIE | !! Win. XDomainRequest,
IsWebkit =! IsTrident &&! Navigator. taintEnabled;
Return {
// Browser sniffing
IsIE: isIE,
IsIE6: isIE &&(! Win. XMLHttpRequest | !! Win. XMLHttpRequest. constructor ),
IsIE7: isIE &&!! Win. XMLHttpRequest &&! Win. XMLHttpRequest. constructor &&! Win. XDomainRequest,
IsIE8: isIE &&!! Win. XDomainRequest,
IsIE9 :! IsIE &&!! Win. XDomainRequest,
IsMaxthon :! Win. opera &&!! Win. external & typeof external. max_version! = 'Undefined', // an exception is thrown when opera reads external. external is null.
IsTT: c (/; TencentTraveler /),
Is360: c (/; 360 /),
IsSogou: c (/; SE \ d \./),
// Rendering engine sniffing.
IsWebkit: isWebkit, // safari chrome KHTML rendering engine .!! + '\ V1' prevents ie 6 from reporting errors
IsGecko :!! Document. getBoxObjectFor | win. policinnerscreenx! = Null, // firefox Rendering Engine
IsTrident: isTrident, // ie Rendering Engine
IsPresto :!! Win. opera, // opera Rendering Engine
// Extended sniffing
// Determine whether it is a high-speed sougou Browser
IsFastModeSogou: isWebkit &&!! Win. external & win. external. propertyIsEnumerable ('startpagecall '),
// Determine whether it is a high-speed sougou browser and need to trigger reflow (sougou2.0 fastMode) in flash mode)
IsFastModeSogouNeedReflow: isWebkit &&!! Win. external & win. external. propertyIsEnumerable ('startpagecall ')&&! ('Localdb' in external ),
// Determine whether it is a high-speed QQ5 Browser
IsFastModeQQ: isWebkit & win. external & 'webcorver 'in external,
// Determine whether iframe is supported to fix the flash div bug
IsIframeOnFlash: isTrident | function () {for (var o in {,}) return o = '0'; return '_'} () | (win. export innerscreenx = null &&!! Document. getBoxObjectFor)
};
} (Win. navigator. userAgent );