Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用javascript检查应用程序是否已安装_Javascript_Android_Html_Google Play - Fatal编程技术网

如何使用javascript检查应用程序是否已安装

如何使用javascript检查应用程序是否已安装,javascript,android,html,google-play,Javascript,Android,Html,Google Play,我正在使用javascript检查是否安装了应用程序,如果安装了我的应用程序,我想打开我的应用程序,否则它将重定向到play store帐户。问题是,即使我已经安装了应用程序,它也会重定向到play store 这是我检查应用程序的.html文件 <!DOCTYPE html> <html> <body> <script type="text/javascript"> window.onload =

我正在使用javascript检查是否安装了应用程序,如果安装了我的应用程序,我想打开我的应用程序,否则它将重定向到play store帐户。问题是,即使我已经安装了应用程序,它也会重定向到play store

这是我检查应用程序的.html文件

 <!DOCTYPE html>
<html>
    <body>
        <script type="text/javascript">
            window.onload = function() {
                // Deep link to your app goes here
                document.getElementById("l").src = "intent://sdf/SplashScreen#Intent;scheme=vsd;package=com.sdf.android.ff;end";

                setTimeout(function() {
                    // Link to the App Store should go here -- only fires if deep link fails                
                    window.location = "https://play.google.com/store/apps/details?id=com.sdf.android.dffd";
                }, 500);
            };
        </script>
        <iframe id="l" width="1" height="1" style="visibility:hidden"></iframe>
    </body>
</html>

window.onload=函数(){
//您的应用程序的深层链接位于此处
document.getElementById(“l”).src=”intent://sdf/SplashScreen#Intent;scheme=vsd;package=com.sdf.android.ff;end”;
setTimeout(函数(){
//应用商店的链接应该放在这里——只有深层链接失败时才会触发
window.location=”https://play.google.com/store/apps/details?id=com.sdf.android.dffd";
}, 500);
};
用这种方法解决它

<html>
<head>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script>


var fallbackToStore = function() {
  window.location.replace('https://play.google.com/store/apps/details?id=packgename');
};
var openApp = function() {
  window.location.replace('intent://app/SplashScreen#Intent;scheme=app_;package=com.sdf.android.dsds;end');
};
var triggerAppOpen = function() {
  openApp();
  setTimeout(fallbackToStore, 700);
};

triggerAppOpen();

</script>
</head>
<body>

</body>

</html>

var fallbackToStore=函数(){
window.location.replace('https://play.google.com/store/apps/details?id=packgename');
};
var openApp=function(){
window.location.replace('intent://app/SplashScreen#Intent;scheme=app;package=com.sdf.android.dsds;end');
};
var triggerAppOpen=函数(){
openApp();
设置超时(回退存储,700);
};
triggerAppOpen();

如果启动了onload,我会感到惊讶——也许在设置源代码之前设置onload,但我仍然认为这是一个失败的错误cause@JaromandaX请检查编辑的问题,现在您已经完全删除了onload-什么可以阻止超时触发?没事,它现在总是会启动,guaranteedright now的问题是,它正在加载play store,即使应用程序已安装或未安装。是的,为什么不加载呢?我尝试了你的解决方案,但超时仍在执行,即使应用程序启动后,苹果商店仍在打开。你是如何做到这一点的?@eugeniobac我认为这个解决方案只适用于安卓系统——它在ios系统上不起作用(因为你提到了苹果商店)。苹果打破了这一限制,实现了通用链接。