iframe是否可以在Cordova的WKWebView中工作? [英] Can iframes work in WKWebView with Cordova?
问题描述
根据Apache Cordova博客,使用WKWebView可能无法使用iframe.( https://cordova.apache.org/news/2018/08/01/future-cordova-ios-webview.html )
According to the Apache Cordova blog, iframes may not work using WKWebView. (https://cordova.apache.org/news/2018/08/01/future-cordova-ios-webview.html)
我在App Store中有一个Cordova应用程序,该应用程序非常依赖iframe.由于UIWebView可能会在iOS 13中删除,是否有一种方法可以使用WKWebView使iframe工作?
I have a Cordova application that is in the App Store that relies quite heavily on iframes. Since UIWebView is likely to be removed in iOS 13, is there a way to get iframes working using WKWebView?
这是我到目前为止所做的:
Here's what I've done so far:
我尝试使用Ionic WebView插件( https://github.com/ionic-team/cordova-plugin-ionic-webview ),尽管它适用于我的应用程序的某些部分,但不适用于iframe页面.具体来说,我正在获取Access-Control-Allow-Origin标头包含无效值'null'.我没有使用UIWebView收到此错误.
I tried using the Ionic WebView plugin (https://github.com/ionic-team/cordova-plugin-ionic-webview), and although it works for parts of my app it does not work on the iframe pages. Specifically, I'm getting Access-Control-Allow-Origin header contains the invalid value 'null'. I don't get this error using UIWebView.
推荐答案
将此添加到您的Cordova config.xml
Add this to your Cordova config.xml
<allow-navigation href="http://*.yourdomain.com/*" />
这将允许您的HTML页面(无论是iframe中的根文档还是子文档)从本地主机重定向到远程URL.
It will allow your HTML pages, no matter root documents or children in the iframe, to redirect from localhost to a remote URL.
这篇关于iframe是否可以在Cordova的WKWebView中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!