zoukankan      html  css  js  c++  java
  • javascript检测浏览器类型和版本号(兼容各浏览器)

    代码
     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 
     
  • 相关阅读:
    Git小结---So far.......
    Git命令之:git push
    Git详解之:Git分支
    使用Dom4j解析XML
    crm客户资源显示控制
    crm---本项目的权限控制模式
    在mybatis中,在列表分页查询过程中造成集合属性数据丢失的问题
    在easyui中解决使west和center为1:1,并且拖动窗口时能够自适应变化
    在springmvc中使用requestContextListener获取全部的request对象
    HTML 元素标签语义化及使用场景
  • 原文地址:https://www.cnblogs.com/geovindu/p/1712345.html
Copyright © 2011-2022 走看看