function judgePcAndMobile(){
// //alert("目前的地址:"+location.href)
var mobileAgent = new Array("iphone", "ipod", "ipad", "android", "mobile", "blackberry", "webos", "incognito",
"webmate", "bada", "nokia", "lg", "ucweb", "skyfire");
var browser = navigator.userAgent.toLowerCase();
// //alert(browser)
console.log(browser.match('android'))
var isMobile = false;
if (
browser.match('iphone') !== null || browser.match('ipod') !== null || browser.match('ipad') !== null ||
browser.match('android') !== null || browser.match('mobile') !== null || browser.match('blackberry') !== null || browser.match('webos') !== null ||
browser.match('incognito') !== null ||browser.match('webmate') !== null ||browser.match('nokia') !== null ||
browser.match('lg') !== null ||browser.match('ucweb') !== null || browser.match('skyfire') !== null
)
{
// alert("是否进入判断是手机")
isMobile = true;alert(mobileAgent[i]);
if(location.href.match('网址') !== null){
//alert("我已经是手机端网址了")
return
}else{
//alert("跳转手机端网址手机端网址了")
location.href = '网址';
return
}
}else{
if(location.href.match('网址') !== null){
//alert("我已经是pc端网址了")
return
}else{
location.href = '网址';
//alert("跳转pc端网址了")
return
}
}
}
judgePcAndMobile()
移动端与pc端的自动识别与跳转
最新推荐文章于 2024-02-07 17:40:04 发布