Now there are probably several browsers, individual preferences are also different, so the use of different browsers! The people we develop often have to add a judgment that it is impossible for certain functions to be used properly. If you don't make a judgment, you'll get us some trouble! Although perhaps everyone's preferences are different! The system is also different! Some people like to use IE, Firefox, and some people like to use Tencent Tt,maxthon and so on. Although the name may have many kinds of, but the kernel we know that there is no problem. such as the IE kernel: Ie,maxthon,tt are. And of course, Netscape's core! See how people Judge!
Because of this problem during development. So look for information and their own summary of the following JS code:
The code is as follows:
Copy Code code as follows:
<script language= "JavaScript" type= "Text/javascript" >
if ((Navigator.userAgent.indexOf (' msie ') >= 0) && (navigator.userAgent.indexOf (' Opera ') < 0)) {alert (' You are using IE ')}else
if (navigator.userAgent.indexOf (' Firefox ') >= 0) {alert (' You are using Firefox ')}else
if (Navigator.userAgent.indexOf (' opera ') >= 0) {alert (' You are using Opera ')}else
{alert (' You are browsing the Web with other browsers! ')}
</script>
Or the following code can also be
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<TITLE>JS Check what is the browser </title>
<script language= "JavaScript" type= "Text/javascript" >
function Checkfirefoxorie () {
Useragent=window.navigator.useragent.tolowercase ();
if (Useragent.indexof ("Firefox") >=1) {
Findex=useragent.indexof ("firefox/");
Versionname=useragent.substr (findex+ "firefox/". length,3);
document.write ("You are using Firefox!") Version is: firefox/"+versionname+" "<br>");
}
else {
var name=navigator.appname;
if (name== "Microsoft Internet Explorer") {document.write ("You are using IE browser!") ");}
}
}
</script>
<body onload= "Checkfirefoxorie ();" >
</body>