如何实现每个电脑端页面判断是否手机查看跳转手机端页面
博主:紫藤心-迷途
浏览次数:3521次
如何实现每个电脑端页面判断是否手机查看跳转手机端页面?比如:
http://www.xxx.com/
手机端访问跳转
http://m.xxx.com
这个我们通常用js来处理就可以了,这段代码放到PC模板中,检测后会自动跳转到手机端模板。
(function(){ if(/iphone|nokia|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|wap|mobile/i.test(navigator.userAgent.toLowerCase())){
var mobileurl = window.location.href.replace('www','m');
window.location.href=mobileurl;
}})();