抑制Safari无法打开页面,因为地址无效?自定义应用启动 [英] Suppress Safari can't open the page because the address is invalid? custom app launch

查看:2436
本文介绍了抑制Safari无法打开页面,因为地址无效?自定义应用启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过iphone上的网络浏览器启动自定义应用。

I'm launching a custom app from a web browser on the iphone.

如果未安装该应用程序,我将重定向到网站上的网页。

If the app is not installed I am redirecting to a web page on the website.

如果是安装它进入应用程序的特定页面

If it is installed it goes to a specific page on the app

这一切都按预期工作,除了大约1/2秒的徒步旅行显示模式窗口说明如下

This all works as expected except for about 1/2 a second safari displays a modal window saying the following

无法打开页面
Safari无法打开页面,因为地址无效。

Cannot Open Page Safari cannot open the page because the address is invalid.

我知道地址无效,我想知道是否可以在Safari中抑制错误信息。

I know the address is invalid and I would like to know if its possible to suppress the error message in safari.

谢谢

推荐答案

我找到了一个适用于此的解决方案。我使用了25ms的setTimeout。但出于某种原因,在nexus 5上我需要将其降低到5ms。

I did find a solution that worked for this. I had it working with a setTimeout of 25ms. But for some reason on a nexus 5 I needed to drop it down to 5ms.

我最终使用了以下内容:

i ended up using the following:

    function goToApp(appLocation, fallbackLocation) {

        setTimeout(function() {
            window.location = fallbackLocation;
             }, 5);
       window.location = "nativeappURL://" + appLocation;
    }

    function goToWeb(baseurl, webLocation) {
        window.location =baseurl + "/"+ webLocation;
    }
</script>

然后我只有两个按钮

 onclick="goToApp('appDestination', 'location')"

 onclick="goToWeb('webDestination', 'location')"

这篇关于抑制Safari无法打开页面,因为地址无效?自定义应用启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆