zoukankan      html  css  js  c++  java
  • js检测是否手机浏览的函数

    查看一个web应用的时候查看源代码无意发现的,记录一下,万能什么时候能用得着呢!

    function isMobile()
    {
        var mobile = navigator.userAgent.match(/iphone|android|phone|mobile|wap|netfront|x11|java|operamobi|operamini|ucweb|windowsce|symbian|symbianos|series|webos|sony|blackberry|dopod|nokia|samsung|palmsource|xda|pieplus|meizu|midp|cldc|motorola|foma|docomo|up.browser|up.link|blazer|helio|hosin|huawei|novarra|coolpad|webos|techfaith|palmsource|alcatel|amoi|ktouch|nexian|ericsson|philips|sagem|wellcom|bunjalloo|maui|smartphone|iemobile|spice|bird|zte-|longcos|pantech|gionee|portalmmm|jig browser|hiptop|benq|haier|^lct|320x320|240x320|176x220/i)!= null;
        return mobile;
    }

    我以前写过一个比较粗略的,粗略到不行的:

    function isMobile(){
        if(navigator.userAgent.toLowerCase().indexOf('mobile')<0)return false;
        else return true;
    }
  • 相关阅读:
    【后端】Python学习笔记
    【学习】JennyHui学英语
    【学习】JennyHui学英语
    【英语】Bingo口语笔记(3)
    LoadRunner目录分析
    性能测试常见用语
    [转]黑盒测试用例设计方法
    RUP
    软件质量管理杂谈
    关于BUG
  • 原文地址:https://www.cnblogs.com/dragondean/p/js-ismobile.html
Copyright © 2011-2022 走看看