判断设备 进行pc与移动端的页面分流

function  isDevice() {
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) {
window.location.href=‘../mobile/default.html‘;
} else {
window.location.href=‘../pc/index.html‘;
}
}

isDevice() ;

原文地址:https://www.cnblogs.com/wjhaaa/p/8868152.html

时间: 2024-09-30 16:33:15

判断设备 进行pc与移动端的页面分流的相关文章

判断设备(PC,安Android,iOS)

//判断是不是PC function IsPC() { var userAgentInfo = navigator.userAgent; var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"); var flag = true; for (var v = 0; v

JS检测当前设备是PC还是移动端

用到的时候找到的分享下,也是收藏下,本地收藏多了感觉找起来很麻烦 方法1: function IsPC() { var userAgentInfo = navigator.userAgent; var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; var flag = true;

js判断终端是PC还是移动端

function IsPC() { var userAgentInfo = navigator.userAgent; var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"); var flag = true; for (var v = 0; v < Agent

js判断手机还是pc并跳转相关页面

<script type="text/javascript"> function GetRequest() { var url = location.search; //???url??"?"???????? var theRequest = new Object(); if (url.indexOf("?") != -1) { var str = url.substr(1); strs = str.split("&

Jquery 判断设备

判断设备是PC端,还是移动端 1 //判断设备 alert 20160512 2 var ua = navigator.userAgent.toLocaleLowerCase(); 3 var pf = navigator.platform.toLocaleLowerCase(); 4 var isAndroid = (/android/i).test(ua)||((/iPhone|iPod|iPad/i).test(ua) && (/linux/i).test(pf)) 5 || (/u

判断浏览器是pc端和移动

/** * 判断浏览器是pc端和移动端,并跳转到不同页面 */ function browserRedirect() { var sUserAgent = navigator.userAgent.toLowerCase(); var bIsIpad = sUserAgent.match(/ipad/i) == "ipad"; var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os"; var bI

js判断设备类型是移动设备还是PC设备

时下,许多web网站都有自己的手机建站,当用移动设备浏览网站的时候,我们希望能跳转到手机网址上,下面是一套并不是很完善的代码,高手可继续完善. 代码贴出: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>js判断设备类型是移动设备还是PC设备</title> <script type="t

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

var ua = navigator.userAgent; var browser = {}, weixin = ua.match(/MicroMessenger\/([^\s]+)/i), webkit = ua.match(/WebKit\/([\d.]+)/i), android = ua.match(/(Android)\s+([\d.]+)/i), ipad = ua.match(/(iPad).*OS\s([\d_]+)/i), ipod = ua.match(/(iPod).*OS

MVC下判断PC和移动端

MVC下的PC端和移动端,其实没区别,写法都一样,只是有两点才改变了它们 第一点:就是单击这个页面任何地方的时候判断是移动端还是客户端: 第二点:新建手机端区域Areas(简单来说:Areas就相当于小的一个运行机制也有控制器-视图-和路由地址),Moble(手机端存放的地方) :MVC运行的机制简单来说就是- 控制器-主页面-是否模板页-返回单击的页面 :关键点就在这个模板页里面(_layout)以及自带的js, :当我们运行到了(_layout)这里的时候就要判断是否为PC还是手机端,别问我