我不确定如何解决以下错误。有人可以帮助我吗?
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.
答案 0 :(得分:1)
您正在尝试从http网站中访问https网址。 HTTPS和HTTP是不同的协议,导致不匹配。
我认为以下链接可能有所帮助: 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.
或者,如果您只是尝试使用不同的协议访问自己的域,也可以尝试设置Access-Control-Allow-Origin标头。
答案 1 :(得分:0)
尝试使用//而不是在iFrame URL地址源地址中使用http://或https://指定协议。它应该使用网站的协议。