Share two mobile phone access to the PC site automatically jump to the phone-side site code _javascript tips

Source: Internet
Author: User

4G, mobile website has been out of hand, PC end and mobile end of the website coexist. How to get someone to visit your PC-side website directly to the mobile end of the site? You reader, small two on the code! Here it comes!

The first way: the need for mobile phone-side also web page data synchronization

Copy Code code 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>

The second method:

 <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 part of the mobile phone system does not know the information, here is a temporary special identification if (navigator.platform.indexOf (' IPad ')!=-1) {window.location=url; //Do this part because the Android phone's kernel is also Linux//But navigator.platform display information is different, so from the browser, that is, using navigator.appversion information to make a judgment 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 Functions Array.prototype.in_array = function (e) {for (i=0;i<this.length;i++) {if (this[i] = e) r
 Eturn true;
 return false; } mobile_device_detect ("http:. ***.com "); </SCRIPT>

Note here the
Mobile_device_detect ("http://***.***.com");//The address inside is filled with the website address of your mobile end.

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.