zoukankan      html  css  js  c++  java
  • js区分移动设备与PC

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>无标题文档</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <link type="text/css" rel="stylesheet" media="screen" href="http://mat1.gtimg.com/www/base/base.css" />
    </head>
    <body>
    <!-- 区分移动端与PC端代码一 ipad属于移动端-->
    <script type="text/javascript">
    if (/iphone|nokia|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|wap|android|iPod|iPad/i.test(navigator.userAgent.toLowerCase())) {
    //添加移动端代码(包含ipad、iphone等)
    }else{
    //添加pc代码
    }
    </script>
    
    <!-- 区分移动端与PC端代码二 ipad属于PC端-->
    <script type="text/javascript">
    if (/iphone|nokia|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|wap|android|iPod/i.test(navigator.userAgent.toLowerCase())) {
    //添加移动端代码(不包括IPAD)
    }else{
    //添加pc代码(包含ipad、iphone等)
    }
    </script>
    </body>
    </html>
  • 相关阅读:
    C语言寒假大作战01
    C语言I作业12—学期总结
    C语言I博客作业11
    C语言I博客作业10
    C语言I博客作业09
    C语言I博客作业08
    C语言寒假大作战04
    C语言寒假大作战03
    C语言寒假大作战02
    C语言寒假大作战01
  • 原文地址:https://www.cnblogs.com/huntaheart/p/3727740.html
Copyright © 2011-2022 走看看