我在Chrome中遇到了问题(在本地运行文件),当我尝试更改iframe内部的iframe的src时,会出现以下错误信息:
Error = Uncaught SecurityError: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match.
这是我用来检索iframe的代码。
Error = Uncaught SecurityError: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match.
这是我用来检索iframe的代码。
iframe = $("iframe").contents().find('iframe');
iframe.attr("src", url);`
当我将文件上传到服务器时,我不会遇到这个问题。但是如果我在本地打开它们,就会出现错误。
在Firefox和Safari中运行良好。
如何在Chrome和其他浏览器中解决这个问题?
iframes
还是一个文档内的一个iframe
?感谢分享。 - guest271314