只要在index.htm首页模板中加入下面这段代码就可以了。
<script type="text/javascript">
if(window.location.toString().indexOf('pref=padindex') != -1) {} else {
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|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
window.location.href = "/m/index.php";
} else if(/iPad/i.test(navigator.userAgent)) {} else {}
} catch(e) {}
}
}
}
</script>
if(window.location.toString().indexOf('pref=padindex') != -1) {} else {
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|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
window.location.href = "/m/index.php";
} else if(/iPad/i.test(navigator.userAgent)) {} else {}
} catch(e) {}
}
}
}
</script>
志博日记是一个专注分享互联网技术的博客,博客网址:www.zhiboblog.com
如果有什么问题,可以联系志博的QQ/微信:1662866246
关注志博公众号,更多干货等着你