This article introduces how to use JS to call APP code. This article shares the following code for using JS to call an APP:
/* Within ms, an application on the local machine can parse the corresponding protocol, open the program, and call the application. If no application on the local machine can parse the Protocol or does not open the program within ms, then, execute the function in setTimeout to jump to the download page. IosAppId: appId iphoneSchema: IOS App protocol iosAppDownloadUrl: IOS App https://itunes.apple.com/cn/app/id@appId@ AndroidSchema: Androind App protocol androidAppDownloadUrl: Androind App */function opendApp (iosAppId, iphoneSchema, iosAppDownloadUrl, androidSchema, androidAppDownloadUrl) {if (navigator. userAgent. match (/(iPhone | iPod | iPad );? /I) {// IPhone var loadDateTime = new Date (); window. setTimeout (function () {var timeOutDateTime = new Date (); if (timeOutDateTime-loadDateTime <5000) {window. location = iosAppDownloadUrl. replace ("@ appId @", iosAppId); // IOS App} else {window. close () ;}}, 25); window. location = iphoneSchema; // IOS App Protocol} else if (navigator. userAgent. match (/android/I) {// Androind try {window. location = androidSchema; // Androind App protocol setTimeout (function () {window. location = androidAppDownloadUrl; // Androind App }, 500);} catch (e ){}}}
The above is the details of using JS to call the APP Code. For more information, see other related articles in the first PHP community!