【问题标题】:Open external URL in cordova webview (NOT inAppBrowser)在 cordova webview 中打开外部 URL(不在 AppBrowser 中)
【发布时间】:2017-08-14 06:19:43
【问题描述】:

我想做什么? 在默认情况下加载 index.html 文件的内部 cordova webview 中打开外部 URL。

我不想做什么,为什么? 使用 inAppBrowser,因为 (1) 在 android 中它显示地址栏。 (2) 网站的外部 URL 使得人们经常在那里发布链接。它们都在 inAppBrowser 中打开。我希望它们在手机的不同浏览器中打开。

到目前为止我做了哪些尝试但没有成功?

(1) window.location.href="http://www.example.com";

(2) window.open('http://www.example.com', '_self ', 'location=yes');

(3) var url = 'http://www.example.com'; var target = '_blank'; var options = "location=yes, toolbar=no"; var ref = cordova.InAppBrowser.open(url, target, options);

(4) 在 index.html 中使用 iframe <iframe src="http://www.example.com ></iframe>

(5) <allow-navigation href="http://*/*" /> <allow-navigation href="https://*/*" /> <allow-navigation href="tel:*" /> <allow-navigation href="sms:*" /> <allow-navigation href="mailto:*" /> <allow-navigation href="geo:*" />

任何线索都会有所帮助。非常感谢各位!

【问题讨论】:

  • 你安装了cordova-plugin-whitelist吗?你知道你可以从 inAppBrowser 中删除地址栏吗?
  • 非常感谢您的回复。 &lt;allow-navigation href="*://*.example.com/*" /&gt; 和 window.location="http://www.einros.com"; 为我工作。

标签: javascript android cordova webview phonegap-plugins


【解决方案1】:

随着 Apple 的新 WKWebView 要求,这变得很草率。没有白名单等对我有用,我也不能使用 InAppBrowser.open 现在 window.open 和 _system 目标。我最终使用了这个插件并解决了。

https://github.com/PaoloMessina/OpenUrlExt

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多