简体   繁体   中英

Open external URL in cordova webview (NOT inAppBrowser)

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.

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.

What have I tried so far without success?

(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) 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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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