Html5 write link to open ios and android local applications

Source: Internet
Author: User

Html5 write link to open ios and android local applications

1. Set links in html

 

Href = "[scheme]: // [host]/[path]? [Query]"
Scheme can be set to any one in the app, and the android and ios settings are the same.
2. If the local application exists, open the app directly. If the application does not exist, jump to the appstore for a period of time.
Determine whether the browser is ios or android.

Var openApp = function () {var btnOpenApp = document. getElementById (open-app); btnOpenApp. onclick = function () {// open the local application function var open = function (url) {var timeout; function try_to_open_app () {timeout = setTimeout (function () {window. location. href = url; console. log (22)}, 10);} try_to_open_app ();} if (/android/I. test (navigator. userAgent) {// alert (This is Android 'browser .); // This is the browser if (/MicroMessenger/I. test (navigator. userAgent) {alert (This is MicroMessenger browser, please open it in a local browser); // This is a platform browser} else {open (andorid app market url );}} if (/(iPhone | iPad | iPod | iOS)/I. test (navigator. userAgent) {// alert (This is iOS 'browser .); // This is the browser if (/MicroMessenger/I. test (navigator. userAgent) {alert (the built-in browser does not support opening local applications. Please click to open the local browser in the upper right corner ); // This is the platform's browser} else {open (ios app market url );}}};}

 

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.