【问题标题】:errorUrl in Cordova Config not working on AndroidCordova Config 中的 errorUrl 无法在 Android 上运行
【发布时间】:2018-07-05 13:34:32
【问题描述】:

当按照docs 中的描述在 config.xml 中设置 errorUrl 时,我会收到一个错误提示

CordovaWebViewImpl: showWebPage: Refusing to load URL into webview since it is not in the <allow-navigation> whitelist. URL=error.html

然后我会看到默认的 android 错误页面。

【问题讨论】:

    标签: javascript java android cordova


    【解决方案1】:

    对我来说,将网址更改为

    <preference name="ErrorUrl" value="file:///android_asset/www/error.html" />
    

    工作。您应该在 android 平台部分添加此值,因为这是 android 特定的。

    还要确保不设置

     <allow-intent href="*" />
    

    否则你会看到一个错误,告诉你没有找到处理意图的活动

    ActivityNotFoundException: No Activity found to handle Intent
    

    如果您需要允许网页作为意图,请考虑添加

    <allow-intent href="http://*/*" /> <allow-intent href="https://*/*" />

    改为。

    【讨论】:

    • 您好,此功能是否可以将 HTTP 错误(例如:404 错误)webview 默认页面替换为自定义页面。我正在 InAppBrowser 中加载一个以“_blank”为目标的网站。
    • 我有一个 Config.xml,我在内容 src 中指定了一个 webapge,但对我来说,没有显示作为错误页面的 errorUrl 值。帮助!!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-04
    • 2022-12-02
    • 2013-10-29
    • 2016-05-27
    • 1970-01-01
    相关资源
    最近更新 更多