I have an iframe on http://mysite.dev:3000
, and a script on this page will set the iframe src attribute to http://mysite.dev:5000/somepage.html
.
After the iframe gets loaded, I want to access its contents by using this script (on http://mysite.dev:3000):
$('iframe').load(function() {
$('iframe').contents();
});
And I always get the error:
Uncaught SecurityError: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin.
Event though, the response header from http://mysite.dev:5000/somepage.html
follows CORS guideline:
Accept-Ranges:bytes
access-control-allow-credentials:true
access-control-allow-headers:Authorization, X-Requested-With, Content-Type, Origin, Accept
access-control-allow-methods:GET,PUT,POST,DELETE,OPTIONS
access-control-allow-origin:*
Cache-Control:public, max-age=0
I read several questions on SO and follow them, still it didn't work.