js 判断是否为手机端
答案:1 悬赏:60 手机版
解决时间 2021-04-04 04:26
- 提问者网友:戎马万世
- 2021-04-04 01:09
js 判断是否为手机端
最佳答案
- 五星知识达人网友:往事埋风中
- 2021-04-04 02:15
var bForcepc=fGetQuery("dv")=="pc";
function fBrowserRedirect(){
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||bIsAndroid||bIsMidp||bIsUc7||bIsUc||bIsCE||bIsWM
{
alert("手机客户端")
if(!bForcepc){
alert("手机客户端")
}
}
};
function fGetQuery(name){
var sUrl=window.location.search.substr(1);
var r = sUrl.match(new RegExp("(^|&)"+name+"=([^&]*)(&|$)"));
return (r==null ? null : unescape(r[2]));
};
function fBrowserRedirect(){
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||bIsAndroid||bIsMidp||bIsUc7||bIsUc||bIsCE||bIsWM
{
alert("手机客户端")
if(!bForcepc){
alert("手机客户端")
}
}
};
function fGetQuery(name){
var sUrl=window.location.search.substr(1);
var r = sUrl.match(new RegExp("(^|&)"+name+"=([^&]*)(&|$)"));
return (r==null ? null : unescape(r[2]));
};
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯