Code function:
Determine whether an app is installed on a mobile phone or tablet
If it is installed, the app's scheme is called, and the url is passed as a parameter for subsequent operations.
If not installed, go to app store/google play to download the app.
Copy codeThe Code is as follows:
(Function (){
Var openUrl = window. location. search;
Try {
OpenUrl = openUrl. substring (1, openUrl. length );
} Catch (e ){
}
Var isiOS = navigator. userAgent. match ('ipad ')
| Navigator. userAgent. match ('iphone ')
| Navigator. userAgent. match ('ipod '), isAndroid = navigator. userAgent
. Match ('android'), isDesktop =! IsiOS &&! IsAndroid;
If (isiOS ){
SetTimeout (function () {window. location = "itms-apps: // itunes.apple.com/app/?name=/#id]? Mt = 8 ";}, 25 );
Window. location = "[scheme]: // [host]? Url = "+ openUrl;
} Else if (isAndroid ){
Window. location = "intent: // [host]/" + "url =" + openUrl + "# Intent; scheme = [scheme]; package = [package_name]; end ";
} Else {
Window. location. href = openUrl;
}
})();