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 );}}};}