<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://www.jb51.net/" />
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
<meta content="black-translucent" name="apple-mobile-web-app-status-bar-style" />
<meta content="telephone=no" name="format-detection" />
<script src="jq.min.js"></script>
<script>
function sp_isMobile() {
return Boolean(navigator.userAgent.match(/.*(iphone|ipod|android|symbian|nokia|blackberry| rim |opera mini|opera mobi|windows ce|windows phone|up\.browser|netfront|palm-|palm os|pre\/|palmsource|avantogo|webos|hiptop|iris|kddi|kindle|lg-|lge|mot-|motorola|nintendo ds|nitro|playstation portable|samsung|sanyo|sprint|sonyericsson|symbian).*/i) || navigator.userAgent.match(/alcatel|audiovox|bird|coral|cricket|docomo|edl|huawei|htc|gt-|lava|lct|lg|lynx|mobile|lenovo|maui|micromax|mot|myphone|nec|nexian|nook|pantech|pg|polaris|ppc|sch|sec|spice|tianyu|ustarcom|utstarcom|videocon|vodafone|winwap|zte/i));
}
//移动端排除ipad
if(sp_isMobile()&&location.search.indexOf('pc=true')==-&&navigator.userAgent.indexOf('iPad')==-) {
//添加meta 方便移动端获取document.documentElement.clientWidth
document.write('<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />'); //
var tabIndex = getRequestMini('Device');
//alert(tabIndex);
if(tabIndex == "viewPc" || document.documentElement.clientWidth>){
location.href="http://www.baidu.com/";
}else{
//location.href="http://u.pingan.com/upingan/upingan/index.html?mediasource=SC03-Direct-00002";
location.href="http://www.jb51.net/";
}
//格式化URL传进来的参数
function getRequestMini(name) {
return (location.search.match(new RegExp('[&?]' + name + '=([^&]*)', 'i')) || [''])[].split('=')[];
};
} </script>
<script type="text/javascript">
//
</script>
<title>test</title>
</head>
<body>
<div style="width:500px; height: 500px; border: 1px solid #ccc; text-align: center;">
JS终端设备检测
</div>
</body>
</html>

JS判断终端设备跳转PC端、移动端相应的URL的更多相关文章

  1. 如何使用js判断当前页面是pc还是移动端打开的

    1.利用了正则表达式和三目运算符,含义就是如果是移动端打开的话那就跳转到 "https:www.baidu.com/" ,如果不是就跳转到"http://new.baid ...

  2. JS判断当前设备是 PC IOS Andriod

    JS判断当前设备是 PC IOS Andriod <script > window.onload = function(){ var isPc = IsPC(); var isAndroi ...

  3. JS判断设备终端(PC,iPad,iPhone,android,winPhone)和浏览器

    JS判断设备终端(PC,iPad,iPhone,android,winPhone)和浏览器 var ua = navigator.userAgent; var browser = {}, weixin ...

  4. js判断用户是在PC端或移动端访问

    js如何判断用户是在PC端和还是移动端访问.  最近一直在忙我们团队的项目“咖啡之翼”,在这个项目中,我们为移动平台提供了一个优秀的体验.伴随Android平台的红火发展.不仅带动国内智能手机行业,而 ...

  5. js判断用户的浏览器设备是移动端还是pc端

    最近做的一个网站页面中需要根据用户的访问设备的不同来显示不同的页面样式,主要是判断移动设备还是电脑浏览器访问的. 下面给出js判断处理代码,以作参考. <script type="te ...

  6. js判断当前浏览器是pc端还是移动端

    根据用户的访问设备的不同来显示不同的页面样式,主要是判断移动设备还是电脑浏览器访问的. 下面给出js判断处理代码,以作参考. <script type="text/javascript ...

  7. js判断是手机还是PC端

    有时接触一些手机上的适应,需要知道是pc 还是移动端 function IsPC() { var userAgentInfo = navigator.userAgent; var Agents = [ ...

  8. 前端判断用户请求是PC还是移动端

    链接:https://www.zhihu.com/question/20004700/answer/13678113 第一步先在服务器端使用User Agent判断,先匹配出移动设备,这一步可以统计U ...

  9. JS判断手机端和PC端自动跳转

    <script type="text/javascript">     function browserRedirect() {     var sUserAgent ...

随机推荐

  1. BSGS[bzoj2242][bzoj3122]

    数论题. 操作一:直接快速幂就好了. 操作二:我用了exgcd,shy和lyz都喜欢欧拉函数...QAQ最后这块还写错了. 对于ax+by=gcd(a,b)的形式,我们可以把他们变成y'x+p'y=1 ...

  2. Redis Tools

    1. Resources Redis Desktop Manager http://redisdesktop.com/ Redis命令的中文文档 http://redisdoc.com/ Redis安 ...

  3. ps让文字的颜色变成图片的颜色

    第一种: 把某张图片图层置于文字图层之上,右击图片图层-->选择"创建剪贴蒙版"即可.第二种:把某张图片图层置于文字图层之上,并选择图片图层,按住Ctrl键,点击文字图层,载 ...

  4. oracle sql别名

    为sql的字段起一个别名,常以为是可有可无的,但是有时候是必要的. 例如在ibatis中 <!-- 获取已发或待发送的彩信记录列表 --> <resultMap id="m ...

  5. Linux crontab 定时任务命令详解

    一.简介 crontab 命令用于设置周期性被执行的指令.该命令从标准输入设备读取指令,并将其存放于 crontab 文件中,以供之后读取和执行.通常,crontab 储存的指令被守护进程激活, cr ...

  6. BZOJ2769 : YY的快速排序

    将数字离散化并去重,则对于一对逆序对$i<j$,$a_i>a_j$,贡献为$\frac{2}{a_i-a_j+1}$,因此只要对于每个差值统计出对应的逆序对个数即可. 将序列分块,块内平方 ...

  7. bzoj2962 序列操作 题解

    题目大意: 有一个长度为n的序列,有三个操作1.I a b c表示将[a,b]这一段区间的元素集体增加c,2.R a b表示将[a,b]区间内所有元素变成相反数,3.Q a b c表示询问[a,b]这 ...

  8. ACM: HDU 1028 Ignatius and the Princess III-DP

     HDU 1028 Ignatius and the Princess III Time Limit:1000MS     Memory Limit:32768KB     64bit IO Form ...

  9. ACM: How many integers can you find-数论专题-容斥原理的简单应用+GCD

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

  10. CF 71C. Round Table Knights

    题目链接 很多小的细节都没想到... #include <cstdio> #include <cstring> #include <iostream> #inclu ...