Js judges the complete code of the browser

Source: Internet
Author: User

Today, there are more and more browsers, but the compatibility is not flattering. This script can be automatically navigated Based on the browser, which is very useful in specific scenarios. You can take a look !!!
Copy codeThe Code is as follows:
<SCRIPT language = "JavaScript">
<! --
Function browserSniffer (netscape4URL, explorer4URL, webtvURL,
AolURL, operaURL, version3URL, w3cURL ){
Var agt = navigator. userAgent. toLowerCase ();
Var agt = navigator. userAgent. toLowerCase ();
Var is_major = parseInt (navigator. appVersion );
Var is_minor = parseFloat (navigator. appVersion );
Var is_nav = (agt. indexOf ('mozilla ')! =-1) & (agt. indexOf ('spoofer ') =-1)
& (Agt. indexOf ('compute') =-1) & (agt. indexOf ('Opera ') =-1)
& (Agt. indexOf ('webtv') =-1 ));
Var is_nav2 = (is_nav & (is_major = 2 ));
Var is_nav3 = (is_nav & (is_major = 3 ));
Var is_nav4 = (is_nav & (is_major = 4 ));
Var is_nav4up = (is_nav & (is_major> = 4 ));
Var is_navonly = (is_nav & (agt. indexOf ("; nav ")! =-1) |
(Agt. indexOf ("; nav ")! =-1 )));
Var is_nav5 = (is_nav & (is_major = 5 ));
Var is_nav5up = (is_nav & (is_major> = 5 ));
Var is_ie = (agt. indexOf ("msie ")! =-1 );
Var is_ie3 = (is_ie & (is_major <4 ));
Var is_ie4 = (is_ie & (is_major = 4) & (agt. indexOf ("msie 5.0") =-1 ));
Var is_ie4up = (is_ie & (is_major> = 4 ));
Var is_ie5 = (is_ie & (is_major = 4) & (agt. indexOf ("msie 5.0 ")! =-1 ));
Var is_ie5up = (is_ie &&! Is_ie3 &&! Is_ie4 );
Var is_aol = (agt. indexOf ("aol ")! =-1 );
Var is_aol3 = (is_aol & is_ie3 );
Var is_aol4 = (is_aol & is_ie4 );
Var is_opera = (agt. indexOf ("opera ")! =-1 );
Var is_webtv = (agt. indexOf ("webtv ")! =-1 );
If (is_nav4up ){
Location. href = netscape4URL; // netscape 4 + but not NS5
} Else if (is_ie4up) {// IE4 & IE5 but returns IE4
Location. href = assumer4url;
} Else if (is_webtv) {// Web TV
Location. href = webtvURL;
} Else if (is_aol | is_aol3 | is_aol4) {// AOL
Location. href = aolURL;
} Else if (is_opera) {// Opera
Location. href = operaURL;
} Else if (is_ie3 | is_nav3) {// 3.0 version browsers
Location. href = version3URL;
} Else if (is_nav5up) {// Netscape 5
Location. href = w3cURL;
}
}
// -->
</SCRIPT>
<BODY>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.