第一种:判断是手机访问还是PC访问

<script>
  function browserRedirect() {
    var sUserAgent = navigator.userAgent.toLowerCase();
    var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
    var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
    var bIsMidp = sUserAgent.match(/midp/i) == "midp";
    var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
    var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
    var bIsAndroid = sUserAgent.match(/android/i) == "android";
    var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
    var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
    if (!(bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) ){

      //跳转到PC端地址
      window.location.href='http://www.jd.com';
    }else{
      //跳转到移动端地址
      window.location.href='http://m.jd.com';
    }
  }

  browserRedirect();
</script>

第二种:判断是手机访问还是PC访问

var system ={};
var p = navigator.platform;
system.win = p.indexOf("Win") == 0;
system.mac = p.indexOf("Mac") == 0;
system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);
if(system.win||system.mac||system.xll){//如果是电脑跳转到百度
  window.location.href="http://www.baidu.com/";
}else{ //如果是手机,跳转到谷歌
  window.location.href="http://www.google.cn/";
}

第三种:判断是手机访问还是PC访问

<script>

if(navigator.platform.indexOf('Win32')!=-1){
  //pc
  //window.location.href="电脑网址";
}else{
  //手机
  window.location.href="手机网址";
}
</script>

第四种:百度判断是手机还是PC访 问

<script src="http://siteapp.baidu.com/static/webappservice/uaredirect.js"type="text/javascript"></script>
<script type="text/javascript">uaredirect("http://m.XXX.com")//手机网址;</script>

将代码网址部分改成你网站的手机网址就Ok,当然可以是任意网址!

第五种:判断是手机还是PC跳转到指定的地址*

下面这段代码是判断浏览器是手机浏览器,然后自动跳转到mobile.com,怎么修改,才能

把不是用手机浏览器的人,在上mobile.com的时候,自动跳转到PC.COM

<script type="text/javascript">

if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|
SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia| SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){
  if(window.location.href.indexOf("?mobile")<0){
    try{
      if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){
        //手机
        window.location.href="http://www.mobile.com";
      }else if(/iPad/i.test(navigator.userAgent)){
        //ipad
        window.location.href="http://ipad.com"
      }else{
        //电脑
        window.location.href="http://pc.com"
      }
    }catch(e){}
  }
}
</script>

判断是手机端还是PC短访问的更多相关文章

  1. js如何判断是手机端还是PC端访问

    function isMobile(){ var sUserAgent= navigator.userAgent.toLowerCase(), bIsIpad= sUserAgent.match(/i ...

  2. js判断是手机端还是pc端访问

    if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) { window.location.href = " ...

  3. PHP判断是手机端还是PC端

    function check_wap() { if (isset($_SERVER['HTTP_VIA'])) return true; if (isset($_SERVER['HTTP_X_NOKI ...

  4. php 判断是否手机端还是pc端

    来自:https://www.cnblogs.com/webenh/p/5621890.html 用手机访问PC端WWW域名的时候,自动判断跳转到移动端,用电脑访问M域名手机网站的时候,自动跳转到PC ...

  5. 获取网页是手机端还是PC端访问

    C#方式: /// <summary> /// 是否手机访问 /// </summary> /// <returns></returns> public ...

  6. 用JS判断用户使用的是手机端还是pc端访问

    最近项目中用到一个应用,当访问同一个网站地址的时候,例如:www.xxx.com的时候,如果当前客户端是pc则跳转到专注于pc的部分,如果当前客户机是手机,则跳转到专注于手机的部分,秉承一贯的习惯,b ...

  7. PHP判断是手机端还是PC访问

    function isMobile(){ $useragent=isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ' ...

  8. 通过代码实现自动判断是手机端还是PC端跳转

    <!-- 2017/09/13 跳转手机页面 start by 小鬼PSer --> <meta name="mobile-agent" content=&quo ...

  9. 判断是手机端还是pc端

    <script type="text/javascript"> if (window.location.toString().indexOf('pref=padinde ...

随机推荐

  1. 在Linux和Windows系统中输出目录结构

    前言 一直以来就想在写文章时,能以文本形式(而不是截图)附上项目的目录结构,今天终于知道怎么操作了,在这分享一下. Linux 首先说下Linux上输出目录结构的方法. yum安装tree 需要支持t ...

  2. win10 将硬盘工作模式由IDE调整到AHCI模式

    第1步:重启进入安全模式 1)点击“开始”按钮 进入设置 2)进入“更新和安全”,“恢复-高级启动”,点击“立即高级启动”, 依次选择“疑难解答”-“高级选项”-“启动设置”-点击“重启” 第2步:进 ...

  3. 记录一次基于docker搭建jira平台

    背景:项目需要选择不同测试平台,筛选一个最佳平台 现状:一台机器安装多套环境,虚拟机太繁琐 解决方案:通过Docker模拟安装测环境 1.pull docker 镜像: jira:7.11.1(目前的 ...

  4. Amazon S3 分布式存储的 python 接口实现

    Amazon s3 是一种分布式的对象存储.用键值对的方式,来存储数据.其中,存入的所有数据都是一个对象(object),每一个对象都有一个键(key)存在. 具有非常方便的 web 访问接口,以及权 ...

  5. 纯数据结构Java实现(1/11)(动态数组)

    我怕说这部分内容太简单后,突然蹦出来一个大佬把我虐到哭,还是悠着点,踏实写 大致内容有: 增删改查,泛型支持,扩容支持,复杂度分析.(铺垫: Java语言中的数组) 基础铺垫 其实没啥好介绍的,顺序存 ...

  6. Day 02--选题与设计(二)

    1.今天我们主要设计了一下我们微信小程序可以实现的功能,客户操作的基本流程,研究了墨刀这个工具的使用方法并试着将想法转化为原型设计项目.我们给自己的系统起名为“天天好餐”.我们认为食堂订送餐与网络上的 ...

  7. SQL Server发布订阅报错:The conversion of a datetime data type to smalldatetime data type resulted in an out of range value.

    执行SQL Server发布订阅时,报错如下信息: The conversion of a datetime data type to smalldatetime data type resulted ...

  8. C++中轻量级多线程openmp

    关于其概念及使用方法: https://baike.baidu.com/item/openmp/3735430?fr=aladdin

  9. Spring学习之旅(十五)--SpringBoot

    在使用 Spring 的过程中,有时候会出现一些 ClassNotFoundException 异常,这是因为 JAR 依赖之间的版本不匹配所导致的.而 Spring Boot 就能避免绝大多数依赖版 ...

  10. 初识JAVA语言

    推荐阅读:  我的CSDN  我的博客园  QQ群:704621321 前言        很多游戏开发者可能会有疑问,你会C#,JS,TS,为什么还要初识JAVA呢?有人可能会说,多学点对自己有好处 ...