第一种:判断是手机访问还是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. ES 27 - Elasticsearch脚本的使用实践

    目录 1 关于脚本 2 脚本使用的最佳实践 2.1 创建脚本并存储 2.2 脚本的缓存 2.3 Script Field - 脚本字段 本文以 ES 6.6.0 版本为例进行演示. 1 关于脚本 ES ...

  2. 高速开车换底盘记:Windows 与 Linux 部署都抗住了,但修车任务艰巨

    抱歉,又是一篇流水账,在排查问题的焦头烂额中写博客的确是一个挑战,望大家见谅. 今天园友溪源More发了一篇博文博客园翻车启示录,而翻车之后的最新进展是——昨天下午我们又把 .net core 引擎的 ...

  3. 白话--长短期记忆(LSTM)的几个步骤,附代码!

    1. 什么是LSTM 在你阅读这篇文章时候,你都是基于自己已经拥有的对先前所见词的理解来推断当前词的真实含义.我们不会将所有的东西都全部丢弃,然后用空白的大脑进行思考.我们的思想拥有持久性.LSTM就 ...

  4. GOF23-单列模式

    1.什么是单例模式 一个类只有一个实列,并且提供一个对外访问该实例的全局访问点. 常见应用场景:数据库连接池,项目中读取配置文件的类,servlet也是单列,Spring中的Bean默认也是单列 2. ...

  5. [HNOI2008]玩具装箱toy(斜率优化dp)

    前言 这是我写的第一道$dp$斜率优化的题目,$dp$一直都很菜,而且咖啡鸡都说了这是基础的东西,然而看别人对$dp$斜率优化一大堆公式又看不懂就老老实实做几道题目,这个比较实在 描述 给出$n$和$ ...

  6. DC6-靶机渗透

    靶场下载链接: Download: http://www.five86.com/downloads/DC-6.zip Download (Mirror): https://download.vulnh ...

  7. java 路径问题

    java路径存在两种写法"/"和"\\" String path="D:\\1.txt"; String path1="D:/1. ...

  8. redux 源码阅读

    目录 [目录结构] [utils] actionTypes.js isPlainObject.js warning.js [逻辑代码] index.js createStore.js compose. ...

  9. PHPstorm 运行时出现 Not Fount 解决办法

    PHPstorm 对默认 localhost 有解析问题,需要手动配置 打开菜单栏 Tools->Deployment->configuration,如下图: 我这是配置完的,你的应该什么 ...

  10. springboot2.X 使用spring-data组件对MongoDB做CURD

    springboot2.X 使用spring-data组件对MongoDB做CURD 使用背景 基于快速开发,需求不稳定的情况, 我决定使用MongoDB作为存储数据库,搭配使用spring-data ...