Console displays Uncaught SecurityError

2019-03-03 22:45发布

I'm not sure how I can fix the error below. Can somebody help me out?

Uncaught SecurityError: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "http://mysite.net" from accessing a frame with origin "https://www.youtube.com". The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "https". Protocols must match.

2条回答
ら.Afraid
2楼-- · 2019-03-03 23:31

Try using // instead of specifying the protocol with http:// or https:// in the iFrame URL address source address. It should use the protocol of the site.

查看更多
beautiful°
3楼-- · 2019-03-03 23:40

You are trying to access an https url from within a http website. HTTPS and HTTP are different protocol and is causing a mismatch.

I think the following link might help: https://productforums.google.com/forum/#!topic/chrome/ODpydGiCgiE

if you want to access frames in a iframe you can change top with 
parent.frames only for accessing frames in the iframe who execute javascript.
try to change top with parent.frames

return top.frames;

return parent.frames;

in google chrome it work for me i can access all my frames in my iframe.

Or if you are just trying to access your own domain with different protocol, you can also try setting the Access-Control-Allow-Origin header.

How does Access-Control-Allow-Origin header work?

查看更多
登录 后发表回答