Determine the type of current device

Source: Internet
Author: User

(function () {var ua = window.navigator.userAgent;var re =/android|ipod|itouch|iphone|ipad| blackberry| symbianos| symbos| Windows Phone os| wap| kindle|pad|pod/i;var iosre =/ipod|itouch|iphone/i;var ipadre =/ipad/i;var androidre =/android/i;if (Re.test (UA)) {//The current device is a mobile devicevar meta = document.getelementsbytagname (' meta ');var Ioslink,andriodlink,ipadlink,h5link;for (Var i=0;i<meta.length;i++) {if (Meta[i].getattribute (' name ') = = ' iOS ') {Ioslink=meta[i].getattribute (' content ');}else if (meta[i].getattribute (' name ') = = ' Android ') {Andriodlink=meta[i].getattribute (' content ');}else if (meta[i].getattribute (' name ') = = ' ipad ') {Ipadlink=meta[i].getattribute (' content ');}else if (meta[i].getattribute (' name ') = = ' h5 ') {H5link=meta[i].getattribute (' content ');}}var url = window.location.href; Current requestif (Url.indexof (' Openapp ') >=0) {//current request contains Openappif (Iosre.test (UA)) {//iOS deviceif (ioslink&&ioslink!= "") {window.location = Ioslink;}}else if (Ipadre.test (UA)) {//Ipadif (ipadlink&& Ipadlink!= "") {window.location = Ipadlink;} }else if (Androidre.test (UA)) {//Android device if (andriodlink&&andriodlink!= "") {document.writeln ("<iframe src=" "+andriodlink+" ' width= ' 100% ' height= ' 2300 ' scrolling= ' no ' Frameborder= ' 0 ' ></Iframe> "); }}else{//Other devices jump H5if (h5link&&h5link!= "") { window.location = H5link; }}if (h5link&&h5link!= "") { SetTimeout ("window.location = '" +h5link+ "';", 2000); }}}}) ();      

Determine the current device type

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.