javascript检测浏览器类型和版本号(兼容各浏览器)
2010-04-15 09:41
645 查看
代码
1 from: http://www.webreference.com/tools/browser/javascript.html 2 http://browserspy.dk/browser.php 3 http://plugins.jquery.com/node/1567/release 4
5 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6 <html xmlns="http://www.w3.org/1999/xhtml">
7
8 <head>
9 <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
10 <title>javascript检测浏览器类型和版本号(兼容各浏览器) </title>
11 <script language="javascript" type="text/javascript">
12 /*
13 geovindu@163.com 涂聚文 捷为工作室,缔友计算机信息技术有限公司
14 from: http://www.webreference.com/tools/browser/javascript.html 15 http://browserspy.dk/browser.php 16 http://plugins.jquery.com/node/1567/release 17 http://www.informit.com/store/product.aspx?isbn=0672328801 18
19 */
20 var uA = navigator.userAgent;
21 var browserType = "unknown";
22 if (uA.indexOf("Opera") > -1) {
23 browserType = "Opera";
24 } else if (uA.indexOf("Safari") > -1) {
25 browserType = "Safari";
26 } else if (uA.indexOf("Konqueror") > -1) {
27 browserType = "Konqueror";
28 } else if (uA.indexOf("Gecko") > -1) {
29 browserType = "Mozilla";
30 } else if (uA.indexOf("MSIE") > -1) {
31 browserType = "Internet Explorer";
32 }
33 //window.alert(browserType);
34 document.write(browserType);
35 document.write("<br/>");
36 document.write(document.lastModified); //显示页面的修改日期
37 document.write("<br/>");
38 document.write(navigator.userAgent); //显示客户端环境参数
39 document.write("<br/>");
40 document.write("h,w:"+screen.availHeight+"x"+screen.availWidth+"pixels");//测定显示器大小
41 //显示器大小
42 function screenWH(){
43 var getscreen=document.getElementById('screenWH');
44 getscreen.value=screen.availHeight+"x"+screen.availWidth;
45 var divscreen=document.getElementById('screensWH');
46 divscreen.value=screen.availHeight+"x"+screen.availWidth+"pixels"; //window.screen.height+"+"+window.screen.width;
47
48 }
49 </script>
50 </head>
51 <body onload="javascript:screenWH();">
52
53 <input type="text" id="screenWH"/>
54 <input type='button' onclick='notEmpty()' value='Form Checker' />
55
56 <br/>
57 <div id="screensWH"></div>
58 </body>
59
60 </html>
61
62
63
1 from: http://www.webreference.com/tools/browser/javascript.html 2 http://browserspy.dk/browser.php 3 http://plugins.jquery.com/node/1567/release 4
5 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6 <html xmlns="http://www.w3.org/1999/xhtml">
7
8 <head>
9 <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
10 <title>javascript检测浏览器类型和版本号(兼容各浏览器) </title>
11 <script language="javascript" type="text/javascript">
12 /*
13 geovindu@163.com 涂聚文 捷为工作室,缔友计算机信息技术有限公司
14 from: http://www.webreference.com/tools/browser/javascript.html 15 http://browserspy.dk/browser.php 16 http://plugins.jquery.com/node/1567/release 17 http://www.informit.com/store/product.aspx?isbn=0672328801 18
19 */
20 var uA = navigator.userAgent;
21 var browserType = "unknown";
22 if (uA.indexOf("Opera") > -1) {
23 browserType = "Opera";
24 } else if (uA.indexOf("Safari") > -1) {
25 browserType = "Safari";
26 } else if (uA.indexOf("Konqueror") > -1) {
27 browserType = "Konqueror";
28 } else if (uA.indexOf("Gecko") > -1) {
29 browserType = "Mozilla";
30 } else if (uA.indexOf("MSIE") > -1) {
31 browserType = "Internet Explorer";
32 }
33 //window.alert(browserType);
34 document.write(browserType);
35 document.write("<br/>");
36 document.write(document.lastModified); //显示页面的修改日期
37 document.write("<br/>");
38 document.write(navigator.userAgent); //显示客户端环境参数
39 document.write("<br/>");
40 document.write("h,w:"+screen.availHeight+"x"+screen.availWidth+"pixels");//测定显示器大小
41 //显示器大小
42 function screenWH(){
43 var getscreen=document.getElementById('screenWH');
44 getscreen.value=screen.availHeight+"x"+screen.availWidth;
45 var divscreen=document.getElementById('screensWH');
46 divscreen.value=screen.availHeight+"x"+screen.availWidth+"pixels"; //window.screen.height+"+"+window.screen.width;
47
48 }
49 </script>
50 </head>
51 <body onload="javascript:screenWH();">
52
53 <input type="text" id="screenWH"/>
54 <input type='button' onclick='notEmpty()' value='Form Checker' />
55
56 <br/>
57 <div id="screensWH"></div>
58 </body>
59
60 </html>
61
62
63
相关文章推荐
- javascript 浏览器类型和版本号检测代码(兼容多浏览器)
- 认识Javascript中的navigator对象以及检测浏览器类型和版本,获取浏览器版本号,检测客户端操作系统
- javascript 检测浏览器类型和版本的代码
- Javascript 跨浏览器基础事件,浏览器检测,判断浏览器的名称、版本号、操作系统
- javascript获取各浏览器的类型和版本号
- javascript 检测浏览器类型、操作系统平台的代码
- Javascript判断浏览器版本和版本号,全兼容
- javascript 检测浏览器类型和版本的代码
- 用javascript判断浏览器的类型和版本号
- Javascript检测浏览器类型以及操作系统
- 检测浏览器版本类型及版本号
- javascript 学习笔记(六)浏览器类型及版本信息检测代码
- 关于javascript判断不同浏览器的类型和版本号
- javascript 检测浏览器版本号
- JavaScript检测浏览器类型
- 各种浏览器的userAgent及如何使用JS来检测游览器类型,或android是什么版本号
- javascript/js 检测浏览器类型和版本,检查浏览器是否支持flash,检查flash版本一站搞定~
- javascript判断当前浏览器类型及版本号
- javascript检测IE6-8,chrome,safari,firefox,opera等主流浏览器类型