(turn) to determine whether IE browser is very simple, with navigator.appname to judge on the line. And Firefox, Chrome, Safari's navigator.appname output values are "Netscape", Now we use navigator.useragent this property to judge, because the Google Chrome navigator.useragent value contains the "Safari" string and the Safari browser does not contain chrome, So we can use this distinction to differentiate between safari and chrome.
The complete code is 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=utf-8" /><title>js perfectly identifies IE, Firefox, Chrome, Safari </title><script>function BrowserType (){var osobject = "";if (navigator.userAgent.indexOf ("MSIE") >0) {osobject = "MSIE";}if (Isfirefox=navigator.useragent.indexof ("Firefox") >0) {osobject = "Firefox";}if (Issafari=navigator.useragent.indexof ("Safari") >0&&navigator.useragent.indexof ("Chrome") <0 ) {osobject = "Safari";}if (Iscamino=navigator.useragent.indexof ("Chrome") >0) {osobject = "Chrome";}return osobject;}function Msg (){document.getElementById ("msg"). InnerHTML = "}</script><body onload= "MSG ()" ><span id= "msg" ></span></body>