gpt4 book ai didi

android - 如何使 phonegap window.location.href 不在 Android 上启动 Chrome

转载 作者:IT王子 更新时间:2023-10-28 23:29:40 25 4
gpt4 key购买 nike

我有一个 phonegap 应用程序。在 deviceReady 上,我将 window.location.href 设置为其他 URL。这在 iOS 8.3 上运行良好,但在 Android 5.0.1 上我被问到是否要在 Chrome 中打开它,然后它在 Chrome 而不是我的应用程序中打开。

有没有办法让 URL 在应用程序中打开(如替换当前页面)。是的,我知道这不是最佳实践,单页应用程序更好,等等等等,但这不适合我目前的用例。

最佳答案

如果您在 android 平台 4.0.0(或更高版本)上使用 cordova 5(或更高版本),请查看:https://github.com/apache/cordova-plugin-whitelist

通过以下方式安装插件:

cordova plugin add https://github.com/apache/cordova-plugin-whitelist.git --save

您需要在 config.xml 中添加:

<allow-navigation href="https://example.com/*" />

多亏了这一点,您将允许 webview 加载您的页面。

关于android - 如何使 phonegap window.location.href 不在 Android 上启动 Chrome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30151385/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com