zoukankan      html  css  js  c++  java
  • web开发中不同设备浏览器的区分

    通常区分不同设备浏览器是用JavaScript中的navigator.userAgent.toLowerCase()方式获取浏览器的userAgent信息

    1 //使用javascript判断是否是iPhone,Android或者ipad的浏览器
    2 if ((navigator.userAgent.match(/iPhone/i))
    3  || (navigator.userAgent.match(/Android/i))
    4  || (navigator.userAgent.match(/Windows Phone/i))
    5  || (navigator.userAgent.match(/MQQBrowser/i))
    6  || (navigator.userAgent.match(/iPod/i))
    7  || (navigator.userAgent.match(/iPad/i))) {
    8   //进行相应的需要的操作
    9 }
     1 //判断是否用微信打开
     2 
     3 function is_weixn() {
     4   var ua = navigator.userAgent.toLowerCase();
     5   if (ua.match(/MicroMessenger/i) == "micromessenger") {
     6      window.location = "tips1.html";
     7   } else { //非微信中打开
     8     window.location = "tips2.html";
     9   }
    10 }
  • 相关阅读:
    c++类的知识点(1)
    并查集经典例题分析
    并查集
    bfs-迷宫
    出栈次序--数学归纳法--蓝桥
    九宫重排
    Tomcat详解
    寒假日记-第三天
    寒假日记-第二天(MySQL语句)
    Java学期总结
  • 原文地址:https://www.cnblogs.com/Steven-shi/p/5129811.html
Copyright © 2011-2022 走看看