繁体   English   中英

在cordova webview中打开外部URL(不是在AppBrowser中)

[英]Open external URL in cordova webview (NOT inAppBrowser)

我想做的事? 打开外部 URL 以在内部cordova webview 中打开,默认加载index.html 文件。

我不想做什么,为什么? 使用 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); 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:*" />

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

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

https://github.com/PaoloMessina/OpenUrlExt

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM