【发布时间】: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 中删除地址栏吗?
-
非常感谢您的回复。
<allow-navigation href="*://*.example.com/*" />和window.location="http://www.einros.com";为我工作。
标签: javascript android cordova webview phonegap-plugins