What is the problem of opening App on H5 page?

window.location.href= "test://com.bhkj.imk"; / / this is the protocol that opens an app
setTimeout (function () {

window.location.href="https://www.baidu.com";

}, 1000);
the above code is executed on the mobile. If the APP is not installed on the phone, it will jump to the Baidu page, and if the APP is already installed on the phone, it will successfully open the APP, but the problem is that if you click on the APP to return to the previous page, it will jump to the Baidu page. Now, is there any way to prevent JS from continuing to jump to Baidu after successfully opening APP?

Jun.16,2021

<html xmlns=http://www.w3.org/1999/xhtml>
<head>
<meta http-equiv=Content-Type content="text/html;charset=utf-8">
<head>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
<title>demo</title>
</head>
<body>
<style>
-sharpzjmobliestart{font-size:40px;}
</style>

<!--
:h5appURLAPPApp StoreAPPapp(360 uc  QQ  )QQ  
-->

<a href="zjmobile://platformapi/startapp" id="zjmobliestart" target="_blank"></a>

<script type="text/javascript"> 
function applink(){  
    return function(){  
        var clickedAt = +new Date;  
         setTimeout(function(){
             !window.document.webkitHidden && setTimeout(function(){ 
                   if (+new Date - clickedAt < 2000){  
                       window.location = 'https://itunes.apple.com/us/app/zhe-jiang-yi-dong-shou-ji/id898243566-sharpweixin.qq.com';  
                   }  
             }, 500);       
         }, 500)   
    };  
}  
document.getElementById("zjmobliestart").onclick = applink();  
</script>   
</body>
</html>

ha, there seems to be nothing. A year ago, when I jumped to app, without installing the ability to open the download page in order to do the installed app, I saw similar code on the NetEase news page. IOS, then take the general link (Universal Links), so that access to the general link page must not be installed, then there is really no way to do Android. I use the same principle as you above, ha


there is no way. Because you finished running in a second. It's possible that the app won't even work. Increase the length of time. Then determine whether the current page is in hidden status. If it is in hidden status, it will not be executed.


use the visibilityChange event to clear the timer when the page is hidden.

specific usage: https://developer.mozilla.org.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3fcf9-2c4d0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3fcf9-2c4d0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?