JS to determine the type of browser and get the version of the browser

Source: Internet
Author: User

<! DOCTYPE html>
<meta charset= "UTF-8" >
<title></title>
<script src= "Js/jquery-1.12.0.min.js" ></script>
<style type= "Text/css" >
. alert {
padding:15px;
margin-bottom:20px;
border:1px solid Transparent;
border-radius:4px;
}
. alert-warning {
Color: #8a6d3b;
Background-color: #fcf8e3;
Border-color: #faebcc;

}

</style>
<script type= "Text/javascript" >
function GetExplorer () {
var explorer = window.navigator.userAgent;
Ie
if (Explorer.indexof ("MSIE") >= 0) {
var browser = navigator.appname;
var b_version = navigator.appversion;
var version = B_version.split (";");
var trim_version = version[1].replace (/[]/g, "");
var number = "";
for (i = 0; i < trim_version.length; i++) {
if ("0123456789". IndexOf (Trim_version.substr (i, 1)) >-1)
Number + = Trim_version.substr (i, 1);
}

if (Number < "8.0") {
if (trim_version = = "MSIE6.0") {
var divname = document.getElementById ("tixing");
var text = "Your browser version is too low (the current browser version is IE6), the system recommends you adopt a high version of the mainstream browser!";
Divname.innerhtml=text;
}
else if (trim_version = = "MSIE7.0") {
var divname = document.getElementById ("tixing");
var text = "Your browser version is too low (the current browser version is IE7), the system recommends you adopt a high version of the mainstream browser!";
Divname.innerhtml=text;
}
else if (trim_version = = "MSIE5.5") {
var divname = document.getElementById ("tixing");
var text = "Your browser version is too low (the current browser version is IE5), the system recommends you adopt a high version of the mainstream browser!";
Divname.innerhtml=text;
}else{
document.getElementById (' tixing '). style.display= ' None ';
}


}else{
document.getElementById (' tixing '). style.display= ' None ';
}
}
Firefox
else if (Explorer.indexof ("Firefox") >= 0) {

document.getElementById (' tixing '). style.display= ' None ';
}
Chrome
else if (Explorer.indexof ("Chrome") >= 0) {

document.getElementById (' tixing '). style.display= ' None ';
}
Opera
else if (Explorer.indexof ("Opera") >= 0) {

document.getElementById (' tixing '). style.display= ' None ';
}
Safari
else if (Explorer.indexof ("Safari") >= 0) {

document.getElementById (' tixing '). style.display= ' None ';
}
}

Window.onload = GetExplorer;
</script>
<body>

<div class= "alert alert-warning" id= "tixing" >

</div>

</body>

JS to determine the type of browser and get the version of the browser

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.