zoukankan      html  css  js  c++  java
  • 判断页面是否手机访问

    var isMobile = {
            Android: function () {
                return navigator.userAgent.match(/Android/i) ? true : false;
            },
            BlackBerry: function () {
                return navigator.userAgent.match(/BlackBerry/i) ? true : false;
            },
            iOS: function () {
                return navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false;
            },
            Windows: function () {
                return navigator.userAgent.match(/IEMobile/i) ? true : false;
            },
            any: function () {
                return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Windows());
            }
        };
        if (isMobile.any()) {
            //如果是手机访问的话的操作!
        }
  • 相关阅读:
    2021-4-1 日报博客
    2021-3-31 日报博客
    2021-3-30 日报博客
    2021-3-29 日报博客
    2021-3-27 周报博客
    java
    周末总结六
    java
    java
    java
  • 原文地址:https://www.cnblogs.com/dyd520/p/15437666.html
Copyright © 2011-2022 走看看