How to automatically jump to the wap website when users enter the URL of the wap mobile website?
How to implement automatic redirection of wap pages?
How to determine whether the visitor is accessing a mobile device and automatically jump to the wap page?
The mobile phone will automatically jump to the mobile phone page. Is a website differentiating between ordinary access and mobile phone access?
If you automatically jump to the wap page when accessing the website domain name on your mobile phone?
This article can solve these problems!
The code copy is as follows:
function is_mobile() {
var regex_match = /(nokia|iphone|android|motorola|^mot-|softbank|foma|docomo|kddi|up.browser|up.link|htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte-|longcos|pantech|gionee|^sie-|portalmm|jigs browser|hiptop|^benq|haier|^lct|operas*mobi|opera*mini|320x320|240x320|176x220)/i;
var u = navigator.userAgent;
if (null == u) {
return true;
}
var result = regex_match.exec(u);
if (null == result) {
return false
} else {
return true
}
}
if (is_mobile()) {
document.location.href= '/wap';
}
The above is the js code, just change /wap to the page you need to jump to.