You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2020/12/03 18:53:05 UTC

[GitHub] [cordova-ios] blukis edited a comment on issue #827: WkWebView breaks iframe working from "cordova.file.dataDirectory" file://

blukis edited a comment on issue #827:
URL: https://github.com/apache/cordova-ios/issues/827#issuecomment-738191106


   I ran into a similar issue with migration to WkWebView.  (Additionally, I needed iframes to run as same origin, despite WkWebView treating anything in file:// as unique-origin.)  This is my workaround:
   ```
   function frameEl_injectHtml(frameEl, injectHtml) {
   	// frameEl must exist in DOM before its contentWindow is accessible.
   	if (!frameEl.contentWindow) { alert("frameInjectHtml() but frameEl not (yet or anymore) in DOM."); return; }
   
   	frameEl.contentWindow.document.open('text/htmlreplace');
   	frameEl.contentWindow.document.write(injectHtml);
   	frameEl.contentWindow.document.close();
   }
   
   // Create <frame>, insert into DOM, and inject content.
   var frameHtml = "<html><head></head>" +
   	"<body style='background-color:#eee; color:#000;'>" +
   		"iframe body" +
   		"<script>window.parent.alert('iframe even same-origin as parent.');</script>" +
   	"</body></html>";
   var frameEl = document.createElement('iframe');
   frameEl.src = "about:blank";
   document.body.appendChild(frameEl);
   frameEl_injectHtml(frameEl, frameHtml);
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org