手机设备访问PC页面如果跳转到手机页面?

//例如:iphone访问www.baidu.com自动跳转到wap.baidu.com,只需在pc端模版页面引入以下js代码
//pc zhuan mobile var mobileAgent = new Array("iphone", "ipod", "ipad", "android", "mobile", "blackberry", "webos", "incognito", "webmate", "bada", "nokia", "lg", "ucweb", "skyfire"); var browser = navigator.userAgent.toLowerCase(); var isMobile = false; for (var i=0; i<mobileAgent.length; i++) { if (browser.indexOf(mobileAgent[i])!=-1) { isMobile = true; location.href = 'http://wap.baidu.com/'; break; } }
原文地址:https://www.cnblogs.com/jewave/p/5048309.html