html源码
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>首页</title><script charset="utf-8" src="phone.js" type="text/javascript"></script><body>pc版本</body></html>
phone.js代码
if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){if(window.location.href.indexOf("?mobile")<0){try{if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){window.location.href="/mobileweb/";}else if(/iPad/i.test(navigator.userAgent)){}else{window.location.href="/mobileweb/"}}catch(e){}}}
如果觉得《当手机访问时自动跳转到手机网站》对你有帮助,请点赞、收藏,并留下你的观点哦!