Js Code automatically jumps to the wap page through wap browsing _ javascript tips-js tutorial

Source: Internet
Author: User
This article describes how to enable users to automatically jump to the wap website when entering the URL of the wap mobile website, for more information, see how to enable users to automatically jump to the wap website when entering the wap mobile website URL?
How does one implement automatic jump of wap pages?
How can I determine whether a visitor is accessed by a mobile device and automatically jumps to the wap page?
The mobile phone automatically jumps to the mobile phone page. Does one website distinguish between regular access and mobile access?
When a mobile phone accesses a website domain name, if it is automatically redirected to the wap page?

This article can solve these problems!

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 js Code only needs to change/wap to the page you need to jump.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.