js判断页面在pc端打开还是移动端打开,分别跳转不同的index.html window.addEventListener('load', function() { // true为手机,false为pc if (!!navigator.userAgent.match(/AppleWebKit.*Mobile.*/)) { //跳转到移动端 window.location.href = window.location.href.concat('m/'); } else if (!navigato…
if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) { //说明是移动端 } else { //说明是pc端 }…
写在前面 在项目中使用html5,需要针对不同的客户端浏览器有不一样的处理方式,这就需要对请求中的useragent进行分析,并进行处理. 一个例子 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Wolfy.RedirectDemo.Default" %> <!DOCTYPE html&…
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…
function IsPC() { var userAgentInfo = navigator.userAgent; var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; var flag = true; ; v < Agents.length; v++) { ) { fl…
/* 获取当前环境: 系统环境: iOS Android PC 浏览器环境 微信内置浏览器.QQ内置浏览器.正常浏览器 是否app内打开 */ var ua = navigator.userAgent.toLowerCase(); //获取浏览器标识并转换为小写 var curConfig = { isiOS: !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //是否苹果 isAndroid: ua.indexOf('a…
<script src="~/Web/js/jquery-1.10.1.min.js"></script> <script> $(function () { window.location.href = /Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent) ? "/Mobile/index.html" : "/Home/WebIndex&quo…
var checkBrowser; 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 = sUserA…
<script type="text/javascript">(function() { //得到域名后缀 var path = location.pathname.split('/') path = path.pop(); var ua = navigator.userAgent.toLowerCase(); var bIsIpad = ua.match(/ipad/i) == "ipad"; var bIsIphoneOs = ua.match(/i…
|)|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) ) { alert("Mobile"); } else { alert("Desktop"); }…