Share two mobile phone access pc website automatically jump to mobile terminal website code, pc automatically Jump

Source: Internet
Author: User

Share two mobile phone access pc website automatically jump to mobile terminal website code, pc automatically Jump

4G has arrived, and mobile websites are already under control. The official websites of PCs and mobile terminals coexist. How can someone else access your pc-side official website and directly jump to a mobile-side website? Look at the code! Coming!

Method 1: Data synchronization between mobile phones and webpages is required.
Copy codeThe Code is as follows:
<Script type = "text/javascript">
(Function () {var ua = navigator. userAgent. toLowerCase (); var bIsIpad = ua. match (/ipad/I) = "ipad"; var bIsIphoneOs = ua. match (/iphone OS/I) = "iphone OS"; var bIsAndroid = ua. match (/android/I) = "android"; var bIsWM = ua. match (/windows mobile/I) = "windows mobile"; if (bIsIpad | bIsIphoneOs | bIsAndroid | bIsWM) {window. location. href = "http://m.jb51.net/android/game/826.html "}})();
</Script>

Method 2:

<Script language = "JavaScript"> function mobile_device_detect (url) {var thisOS = navigator. platform; var OS = new Array ("iPhone", "iPod", "iPad", "android", "Nokia", "SymbianOS", "Symbian ", "Windows Phone", "Phone", "Linux armv71", "MAUI", "UNTRUSTED/1.0", "Windows CE", "BlackBerry", "IEMobile "); for (var I = 0; I <OS. length; I ++) {if (thisOS. match (OS [I]) {window. location = url;} // because a considerable number of mobile phone systems do not know the information, this is a temporary special recognition if (navigat Or. platform. indexOf ('ipad ')! =-1) {window. location = url;} // This is because the kernel of the Android mobile phone is also Linux // But navigator. platform displays a wide range of different information, so you can start with a browser and use navigator. the appVersion information is used to determine var check = navigator. appVersion; if (check. match (/linux/I) {// X11 is the platform of the UC browser. if there are other special browsers, you can attach the condition if (check. match (/mobile/I) | check. match (/X11/I) {window. location = url ;}// class in_array Function Array. prototype. in_array = function (e) {for (I = 0; I <this. length; I ++) {if (this [I] = e) return true;} return false;} mobile_device_detect ("http ://***. ***. com "); </SCRIPT>

Note the following:
Mobile_device_detect ("http: // ***. ***. com"); // enter the address of your mobile website.

Related Article

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.