码迷,mamicode.com
首页 > Web开发 > 详细

web首页设置如下代码可判断用户是用什么设备登录的?

时间:2016-01-30 22:26:00      阅读:242      评论:0      收藏:0      [点我收藏+]

标签:

var OnePage=true;//用来判断staticHtml.js中首页登入的信息判断
var _mobileUrl = "http://www.m.90tuku.com";//手机用户通过手机方式访问网站的饿时候跳转的
checkMobileDevice();//调用监测代码

 

function isMobileDevice(){
return (navigator.userAgent.match(/Android/i) || navigator.userAgent.indexOf(‘iPhone‘) > -1 || navigator.userAgent.indexOf(‘iPod‘) > -1 || navigator.userAgent.indexOf(‘iPad‘) > -1);
}
function isFromWap(){
return (location.href.indexOf("from=wap")>-1);
}
function checkMobileDevice(){
var mobileDevice = isMobileDevice();//检查是否是手持设备过来的
if(mobileDevice){
var formWap = isFromWap();
// if(fromWap!="fromWap"){//检查是否是手机端发送的要登入pc网址
if(!formWap){
location.href = _mobileUrl;
return false;
}
// }
}
}

web首页设置如下代码可判断用户是用什么设备登录的?

标签:

原文地址:http://www.cnblogs.com/swite/p/5171526.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!