search

Home  >  Q&A  >  body text

javascript - How to determine whether an app is installed on iOS on a mobile web page?

How to determine whether an app is installed on iOS on the mobile web page?

学习ing学习ing2747 days ago1087

reply all(1)I'll reply

  • typecho

    typecho2017-07-01 09:14:24

    This question is on segmentfault. The IOS webpage can determine whether an application is installed
    I haven’t looked at it for a long time. Try:

    <script language="javascript">  
     if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {  
      var loadDateTime = new Date();  
      window.setTimeout(function() {  
       var timeOutDateTime = new Date();  
       if (timeOutDateTime - loadDateTime < 5000) {  
        window.location = "要跳转的页面URL";  
       } else {  
        window.close();  
       }  
      },  
      25);  
      window.location = " apps custom url schemes ";  
     } else if (navigator.userAgent.match(/android/i)) {  
      var state = null;  
      try {  
       state = window.open("apps custom url schemes ", '_blank');  
      } catch(e) {}  
      if (state) {  
       window.close();  
      } else {  
       window.location = "要跳转的页面URL";  
      }  
     }  
    </script> 

    reply
    0
  • Cancelreply