yueloveme的博客通过本文主要向大家介绍了js如何判断浏览器,js如何判断浏览器版本,js判断浏览器类型,js怎么判断浏览器版本,js判断浏览器等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
<!DOCTYPE html> <html> <head> <title>Zzhjs5.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <!--<link rel="stylesheet" type="text/css" href="./styles.css">--> <script type="text/javascript"> function myBrowser(){ var userAgent = navigator.userAgent; // if(userAgent.indexOf("Opera")>-1){ return "Opera"; } //火狐 if(userAgent.indexOf("Firefox")>-1){ return "Firefox"; } //谷歌 if(userAgent.indexOf("Chrome")>-1){ return "Chrome"; } //IE if(userAgent.indexOf("IE")>-1){ return "IE"; } //苹果浏览器 if(userAgent.indexOf("Safari")>-1){ return "Safari"; } } function ondivclick(){ alert(myBrowser()); } </script> </head> <body> <input type="button" value="查看浏览器类型" onclick="ondivclick()"/> </body> </html>