JS to determine the best way to move devices and to jump to the mobile version of the Web page

Source: Internet
Author: User

Method One: PureJSJudge

Using this method is both simple and practical, without the need to introduce the jquery library and add the following code to the

<script type= "Text/javascript" >if (/android|webos|iphone|ipad|ipod| blackberry| iemobile| Opera mini/i.test (navigator.useragent)) {window.location = "mobile.html";//Can be replaced with an HTTP address}</script>


Method Two: Use Device.JSLibrary

Device. JS is a device used to check the plug-in, using it you can easily determine the device's operating system, as well as whether the device is portrait or landscape.

First, we download the device. JS

: Https://github.com/matthewhudson/device. JS

STEP 1: IntroductionJSFile
<script src= "Device.min.js" ></script>
STEP 2: Add judgmentCode
<script type= "Text/javascript" >if (Device.mobile ()) {window.location = "shouji.html"; Can be replaced with an HTTP address}</script>


Device. There are many JS methods, if you want to implement the judgment of a device, to replace device.mobile () according to the following code .

650) this.width=650; "alt=" JS to determine the best method of mobile device and to jump to the mobile version of the page "src=" http://static.open-open.com/lib/uploadImg/20151204/ 20151204211230_444.png "width=" "height=" 854 "style=" border:0px;vertical-align:middle; "/>


JS to determine the best way to move devices and to jump to the mobile version of the Web page

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.