簡體   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