if (Navigator.userAgent.match (/android/i)) {
An IFRAME tries to open the app and, if it opens normally, switches directly to the app and automatically blocks the default behavior of the a tag.
Otherwise open the HREF link of the A tag
var isInstalled;
The following is the address of the Android app interface call, to modify their own according to the situation
var ifrsrc = ' Cartooncomicsshowtwo://platformapi/startapp? Type=0&id=${com.id}&phone_num=${com.phone_num} ';
var IFR = document.createelement (' iframe ');
IFR.SRC = IFRSRC;
Ifr.style.display = ' None ';
Ifr.onload = function () {
Alert (' is installed. ');
IsInstalled = true;
alert (isInstalled);
document.getElementById (' OpenApp0 '). Click ();};
Ifr.onerror = function () {
Alert (' May is not installed. ');
isInstalled = false;
alert (isInstalled);
}
Document.body.appendChild (IFR);
SetTimeout (function () {
Document.body.removeChild (IFR);
},1000);
}
iOS judgment
if (Navigator.userAgent.match (/(Iphone|ipod|ipad);? /i)) {
if (Navigator.userAgent.match (/(Iphone|ipod|ipad);? /i)) {
Animation://com.yz.animation
var isInstalled;
var gz = ' {' comname ': ' ${com.short_name} ', ' Comid ': ' ${com.id} ', ' Comphonenum ': ' ${com.phone_num} ', ' type ': ' 0 '} ';
var jsongz =json.parse (GZ);
Here is the address of the iOS call, which you modify according to the situation
var ifrsrc = ' animation://?comname=${com.short_name}&comid=${com.id}&comphonenum=${com.phone_num}& Type=0 '; var IFR = document.createelement (' iframe ');
IFR.SRC = IFRSRC;
Ifr.style.display = ' None ';
Ifr.onload = function () {
Alert (' is installed. ');
IsInstalled = true;
alert (isInstalled);
document.getElementById (' OpenApp1 '). Click ();};
Ifr.onerror = function () {
Alert (' May is not installed. ');
isInstalled = false;
alert (isInstalled);
}
Document.body.appendChild (IFR);
SetTimeout (function () {
Document.body.removeChild (IFR);
},1000);
}
}
The following iOS is available, Android is not available
<meta name= ' Apple-itunes-app ' content= ' app-id=477927812 ' >
- <!--a tag link, set as the corresponding download link; Click the Open action, register in the Click Event--
- <a href="https://itunes.apple.com/cn/app/id477927812" id="Openapp"> Paste Client </ a>
- <script type="Text/javascript">
- document.getElementById (' Openapp '). onclick = function (e) {
- An IFRAME tries to open the app and, if it opens normally, switches directly to the app and automatically blocks the default behavior of the a tag.
- Otherwise open the HREF link of the A tag
- var IFR = document.createelement (' iframe ');
- ifr.src = ' com.baidu.tieba://';
- Ifr.style.display = ' None ';
- Document.body.appendChild (IFR);
- Window.settimeout (function () {
- Document.body.removeChild (IFR);
- },3000)
- };
- </Script>
JS Wake-Up mobile app