在Cordova WebView中打开外部URL(不是inAppBrowser) [英] Open external URL in cordova webview (NOT inAppBrowser)

查看:75
本文介绍了在Cordova WebView中打开外部URL(不是inAppBrowser)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做什么?要打开外部URL,以在内部cordova Web视图中打开,默认情况下将在其中加载index.html文件.

What I want to do? To open an external URL to open in the internal cordova webview, where the index.html file loads by default.

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

What do I not want to do and why? Use the inAppBrowser, because (1) in android it shows the address bar. (2) The external URL of the website is such that people post links there often.. They all open up in the inAppBrowser. I would prefer them to open in a different browser in the phone.

到目前为止,我尝试了什么但没有成功?

(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 =位置=是,工具栏=否";var ref = cordova.InAppBrowser.open(url,target,options);

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

(4) Use an iframe in index.html <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:*"/>

任何线索都将有所帮助.在此先感谢大家!

Any leads would be helpful. Thanks a lot in advance folks!

推荐答案

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

With Apple's new WKWebView requirement, this just got sloppy. None of the whitelisting etc worked for me, nor could I use InAppBrowser.open now window.open with _system target. I ended up using this plugin and solved.

https://github.com/PaoloMessina/OpenUrlExt

这篇关于在Cordova WebView中打开外部URL(不是inAppBrowser)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆