Home > Web Front-end > JS Tutorial > js code to automatically jump to wap page when browsing wap_javascript skills

js code to automatically jump to wap page when browsing wap_javascript skills

WBOY
Release: 2016-05-16 16:48:05
Original
1342 people have browsed it

How to allow users to automatically jump to the wap website when they enter the URL of the wap mobile website?
How to implement automatic jump to the wap page?
How to determine whether the visitor is visiting from a mobile device and automatically jump to the wap page ?
The mobile phone automatically jumps to the mobile page. A URL distinguishes ordinary access and mobile access?
What if the mobile phone automatically jumps to the wap page when accessing the website domain name?

This article can solve these problems!

Copy code The code 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-|portalmmm|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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template