JS 判断移动端 ,跳转

function SetPlatForm() {
    var JumpUrl = "";
    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";
    var ua = window.navigator.userAgent.toLowerCase();
    var url = location.href.toLowerCase();
    if ((bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM)) {
       JumpUrl = url.replace(location.host.toLowerCase(), ‘m.xxx.com‘);
        window.location.href = JumpUrl;
    }else{
     JumpUrl = url.replace(location.host.toLowerCase(), ‘www.xxx.com‘);
     window.location.href = JumpUrl;
    }
}

  

时间: 2024-12-14 10:01:49

JS 判断移动端 ,跳转的相关文章

js判断移动端是否安装某款app的多种方法

第一种方法: 一:判断是那种设备 var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器 var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端 二:安卓设备:原理:判断是否认识这个协议,认识则直接跳转,不认识就在这里下载app android(); if(isAndroid){ function an

js判断移动端或是pc端

Js判断客户端是否为PC还是手持移动设备方法一 function IsPC(){ var userAgentInfo = navigator.userAgent; var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"); var flag = true; for (

JS判断登陆端是PC还是手机

读取navigator.userAgent里面的信息,为了方便利用toLowerCase方法转成小写的形式.然后用MATCH方法进行匹配版本信息,这里提供了多个版本的测试信息,可以用来做后续代码的接口.这里作统一或起来判断登陆端是否是手机~~程序很简单,主要还是丰富JS知识吧.下面是个简单的小例子,希望对你有帮助. <!doctype html> <html> <script type="text/javascript"> function brow

JS判断移动端访问设备并加载对应CSS样式

JS判断不同web访问环境,主要针对移动设备,提供相对应的解析方案(判断设备代码直接copy腾讯网的) // 判断是否为移动端运行环境 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/.

js判断移动端还是PC端

function isMobile(){ var sUserAgent= navigator.userAgent.toLowerCase(), bIsIpad= sUserAgent.match(/ipad/i) == "ipad", bIsIphoneOs= sUserAgent.match(/iphone os/i) == "iphone os", bIsMidp= sUserAgent.match(/midp/i) == "midp", b

js判断移动端与pc端

这里介绍下使用device.js插件来判断移动端设备 地址:https://github.com/matthewhudson/device.js 示例: if(device.mobile()){ window.location.href = "移动端地址"; //alert("移动端"); } else { window.location.href = "PC端地址"; //alert("PC端"); } 更多设备判断如下表格

JS判断移动端还是PC、移动端px转换成rem、移动端圆角

判断PC还是移动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(

js判断移动端手势 上下左右滑动事件

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script src="https://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script> </head> <body style="hei

JS判断按时间跳转到相应的页面

<!--时间段跳转js--><script language="javaScript" type="text/javascript"> var now = new Date();var hour = now.getHours();if(hour <= 8){window.location.href='http://www.lixinedu.cn/2015zsjz/';} else if(hour >=20){window.loca