JS Wake-Up mobile app

Source: Internet
Author: User
Tags switches

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 ' >

  1. <!--a tag link, set as the corresponding download link; Click the Open action, register in the Click Event--
  2. <a href="https://itunes.apple.com/cn/app/id477927812" id="Openapp"> Paste Client </ a>
  3. <script type="Text/javascript">
  4. document.getElementById (' Openapp '). onclick = function (e) {
  5. 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.
  6. Otherwise open the HREF link of the A tag
  7. var IFR = document.createelement (' iframe ');
  8. ifr.src = ' com.baidu.tieba://';
  9. Ifr.style.display = ' None ';
  10. Document.body.appendChild (IFR);
  11. Window.settimeout (function () {
  12. Document.body.removeChild (IFR);
  13. },3000)
  14. };
  15. </Script>

JS Wake-Up mobile app

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.