标签:safari cti sof window tle logs title javascrip gen
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="Generator" content="EditPlus®"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <title>Document</title> </head> <body> </body> <script> function getType() { var nav = navigator, s = nav.userAgent, res = ‘unknow‘; if(s.indexOf(‘Chrome‘) !== -1) { if(nav.languages) { //360目前(6.3)不支持webkitPersistentStorage等以webkit开头的属性 res = ‘Chrome‘; }else { res = ‘360‘; } }else if(s.indexOf(‘Firefox‘) !== -1) { res = ‘Firefox‘; }else if(isIECore()) { if(window.__IE_DEVTOOLBAR_CONSOLE_COMMAND_LINE) { res = ‘360‘; }else { if(s.indexOf(‘MSIE‘) !== -1) { res = s.split(‘;‘)[1].split(‘.‘)[0]; }else { res = ‘MSIE 11‘; } } }else if(s.indexOf(‘Opera‘) !== -1) { res = ‘Opera‘; }else if(s.indexOf(‘Safari‘) !== -1) { res = ‘Safari‘ } return res; } function isIECore() { var boo = true; try{ new ActiveXObject("Microsoft.XMLHTTP"); }catch(e) { boo = false; } return boo; } alert(getType()); </script> 或者下面的写法 <script language="JavaScript"> <!-- function getOs() { var OsObject = ""; if(navigator.userAgent.indexOf("MSIE")>0) { return "MSIE"; } if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){ return "Firefox"; } if(isSafari=navigator.userAgent.indexOf("Safari")>0) { return "Safari"; } if(isCamino=navigator.userAgent.indexOf("Camino")>0){ return "Camino"; } if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){ return "Gecko"; } } alert("您的浏览器类型为:"+getOs()); --> </script> </html>
标签:safari cti sof window tle logs title javascrip gen
原文地址:http://www.cnblogs.com/jinsuo/p/6641160.html