Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Error: Permission denied to access property "x"

消息

Error: Permission denied to access property "x"

错误类型

错误.

什么地方出错了?

尝试访问无权访问的对象。这很可能出现在使用<iframe>元素时加载了一个不同域名下的页面,这在访问子页面时会违背同源策略

示例

<!DOCTYPE html>
<html>
  <head>
    <iframe id="myframe" src="https://www1.w3c-test.org/common/blank.html"></iframe>
    <script>
      console.log(document.getElementById('myframe').contentWindow.document);
      // Error: Permission denied to access property "document"
    </script>
  </head>
  <body></body>
</html>

可以参考

文档标签和贡献者

 此页面的贡献者: neal1991, Jack-Q
 最后编辑者: neal1991,