Can't properly load external URLs in an iframe with cordova iOS

人走茶凉 提交于 2019-12-10 19:29:23

问题


I need help. Anybody knows why I can't consistently load URLs into iframes within phonegap/cordova iOS? I noticed that some pages simply refuse to load inside an iframe while others will load just fine. I also can't seem to get SSL based sites to load. Examples:

<iframe src="http://ucla.edu"></iframe> //loads correctly
<iframe src="http://google.com"></iframe> //refuses to load
<iframe src="http://www.ufrj.br"></iframe> //loads correctly
<iframe src="http://192.168.20.95"></iframe> //loads correctly (this a local server I have inside my work network)
<iframe src="https://192.168.30.15"></iframe> //refuses to load (this also a local server but with a valid ssl cert (signed by startcom/startSSL)

I added stay-in-webview and access origin tags to config.xml (I can load SOME external pages in the iframe) but not sure why this behavior is not consistent. The Mac I'm using to develop can load all these properly.

I am new to this so I am trying things out to wrap my head around the basics before start "porting" my old webApps into mobile platforms. My dev systems has: Lion Cordova 2.5 xCode 4.6

Any help is welcome. Thanks!


回答1:


I think I got it. I will post it here in the case someone else falls in the same misconception I did.

Looking at the response headers in my regular desktop browser I noticed that the pages which won't load in the mobile app iframe have the X-Frame-Options: SAMEORIGIN set in their response headers. This option tells the web-browser NOT to load that page in a frame unless the window belongs to the same origin. Since my iframe doesn't qualify, the page won't load. https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options

I had also (mis)understood the goal of the config.xml whilelisting: That whitelisting is places the app can visit. It has little to do with what can be received by the app. My bad.

I will try working with the childbrowser plugin for cordova and hope for better results. https://github.com/macdonst/phonegap-plugins/tree/master/Android/ChildBrowser

-rod



来源:https://stackoverflow.com/questions/15438054/cant-properly-load-external-urls-in-an-iframe-with-cordova-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!