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 < Agents.length; v++) {
       if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }
   }
   return flag;  }

注:转自http://blog.csdn.net/wz361790599/article/details/8211877

时间: 2024-10-12 13:02:20

js判断终端是PC还是移动端的相关文章

js判断浏览器在PC中打开还是移动设备中打开

var browser = {                            versions: function () {                                var u = navigator.userAgent, app = navigator.appVersion;                                return {         //移动终端浏览器版本信息                                  

js判断客户端是PC还是手持设备

1. function IsPC(){//true为pc,false为手持设备 var userAgentInfo = navigator.userAgent; var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"); var flag = true;   for 

js判断是否是PC,IOS,Android客户端

写在前面 在项目中使用html5,需要针对不同的客户端浏览器有不一样的处理方式,这就需要对请求中的useragent进行分析,并进行处理. 一个例子 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Wolfy.RedirectDemo.Default" %> <!DOCTYPE html&

js判断客户端是pc还是手机

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

.net查询终端是PC还是移动端

public string  IsMobile() { string str_u = Request.ServerVariables["HTTP_USER_AGENT" ]; Regex b = new Regex(@"android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|

js判断用户使用设备及移动端竖屏代码实现

var browser={ versions:function(){ var u = navigator.userAgent, app = navigator.appVersion; return { trident: u.indexOf('Trident') > -1, //IE内核 presto: u.indexOf('Presto') > -1, //opera内核 webKit: u.indexOf('AppleWebKit') > -1, //苹果.谷歌内核 gecko: u.

判断设备 进行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) == &

Java与JS判断请求来是否来自移动端

Java 1 public boolean JudgeIsMoblie(HttpServletRequest request) { 2 boolean isMoblie = false; 3 //String[] mobileAgents = { "iphone", "android", "phone", "mobile", "wap", "netfront", "java&q

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("&