Mobile phone access to the PC website automatically jump to the mobile site code

Source: Internet
Author: User


<SCRIPTLANGUAGE= "JavaScript"> functionmobile_device_detect (URL) {varThisos=Navigator.platform; varOS=NewArray ("IPhone","IPod","IPad","Android","Nokia","SymbianOS","Symbian","Windows Phone","Phone","Linux armv71","MAUI","untrusted/1.0","Windows CE","BlackBerry","Iemobile");  for(varI=0; I<Os.length;i++)        { if(Thisos.match (Os[i])) {window.location=URL;} } //because quite a part of the cell phone system does not know the information, here is to do temporary special identification if(Navigator.platform.indexOf ('IPad') != -1) {window.location=URL;} //This is partly because the core of the Android phone is also Linux //but navigator.platform display information is different, so from the browser, that is, using navigator.appversion information to make judgments  varCheck=navigator.appversion; if(Check.match (/Linux/i)) {//X11 is a platform for UC browsers and can be attached if other special browsers are available   if(Check.match (/Mobile/i)||Check.match (/X11/i)) {window.location=URL; }  } //class In_array functionArray.prototype.in_array= function(e) { for(i=0; I< This. Length;i++)  {   if( This[i]==e)return true; }  return false; } }mobile_device_detect ("");</SCRIPT>

The second type:

<Scripttype= "Text/javascript">Try {varUrlhash=Window.location.hash;if (!Urlhash.match ("Fromapp")){if( (Navigator.userAgent.match (/(iphone|ipod| Android|ios|ipad)/i))) {window.location="";}}}Catch(Err) {}</Script>

Third Kind

<Scripttype= "Text/javascript">//JavaScript DocumentfunctionUrlredirect () {varsuseragent=navigator.userAgent.toLowerCase (); if( (Suseragent.match (/(Ipod|iphone os|midp|ucweb|android|windows ce|windows Mobile)/i )) {//pc Jump Mobile End        varThisurl=window.location.href; Window.location.href=Thisurl.substr (0, Thisurl.lastindexof ('/')+1)+'mobile/'; }}urlredirect ();</Script>

The second one has been tried, yes. But there's a

Window.location.hash. Haven't figured out what it means.

Mobile phone access to the PC website automatically jump to the mobile site code

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: 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.