No longer can access iframe contentWindow since 0.40.0
See original GitHub issueNWJS Version : 0.41.2, bug since 0.40.0 Operating System : CentOS 7.7
Expected behavior
iframe.contentWindow should work.
Actual behavior
FAILED SecurityError: Blocked a frame with origin “chrome-extension://goedajggnemaklpbabiibhndbgcfdmoj” from accessing a cross-origin frame.
How to reproduce
Simplest NW.js app with index.html
<html><head><script>
function showLocation () {
try {
var location = document.querySelector("iframe").contentWindow.location.href;
} catch (e) {
location = `FAILED ${e}`;
}
document.querySelector("p").textContent = location;
}
</script></head>
<body onload="showLocation();">
<p>waiting for onload</p>
<iframe src="http://www.wikipedia.org/"></script>
</body></html>
Until NW.js 0.39.3 after loading page it shows
This example happens to show a change of URL, from http redirected to https.
Since NW.js 0.40.0 and still in NW.js 0.41.2 after loading page it shows
SecurityError: Blocked a frame with origin “chrome-extension://goedajggnemaklpbabiibhndbgcfdmoj” from accessing a cross-origin frame.
This is supposed to work per documentation http://docs.nwjs.io/en/latest/For Users/Advanced/Security in NW.js/ where it says
you can … access to <iframe> element whose src points to remote sites
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
I resolved ths probem, like this: 1\set package.json “chromium-args”:“–disable-web-security’”
2\ Use window.postMessage('what your want to send",“*”) instead of javscript call.
That’s all. It works!
Thanks Roger for reopening the issue. As you probably found out, it doesn’t work even on 0.43.0-beta1. A big thanks for your amazing work!