手机设备访问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; } }
posted @ 2015-12-15 14:51  web全端小屋  阅读(691)  评论(0编辑  收藏  举报