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.

Revision 1081178 of Error: Permission denied to access property "x"

  • Revision slug: Web/JavaScript/Reference/Errors/Property_access_denied
  • Revision title: Error: Permission denied to access property "x"
  • Revision id: 1081178
  • Created:
  • Creator: Bzbarsky
  • Is current revision? No
  • Comment Change the example to have code that will actually throw a security error, as opposed to a "null has no properties" error or some such.

Revision Content

{{jsSidebar("Errors")}}

Message

Error: Permission denied to access property "x"

Error type

{{jsxref("Error")}}.

What went wrong?

There was attempt to access an object for which you have no permission. This is likely an {{HTMLElement("iframe")}} element loaded from a different domain for which you violated the same-origin policy.

Examples

<!DOCTYPE html>
<html>
  <head>
    <iframe id="myframe" src="https://www1.w3c-test.org/common/blank.html"></iframe>
    <script>
      onload = function() {
        console.log(frames[0].document);
        // Error: Permission denied to access property "document"
      }
    </script>
  </head>
  <body></body>
</html>

See also

Revision Source

<div>{{jsSidebar("Errors")}}</div>

<h2 id="Message">Message</h2>

<pre class="syntaxbox">
Error: Permission denied to access property "x"
</pre>

<h2 id="Error_type">Error type</h2>

<p>{{jsxref("Error")}}.</p>

<h2 id="What_went_wrong">What went wrong?</h2>

<p>There was attempt to access an object for which you have no permission. This is likely an {{HTMLElement("iframe")}} element loaded from a different domain for which you violated the <a href="/en-US/docs/Web/Security/Same-origin_policy">same-origin policy</a>.</p>

<h2 id="Examples">Examples</h2>

<pre class="brush: html">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&nbsp; &lt;head&gt;
&nbsp;&nbsp;&nbsp; &lt;iframe id="myframe" src="https://www1.w3c-test.org/common/blank.html"&gt;&lt;/iframe&gt;
&nbsp;&nbsp;&nbsp; &lt;script&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; onload = function() {
        console.log(frames[0].document);
        // Error: Permission denied to access property "document"
      }
&nbsp;&nbsp;&nbsp; &lt;/script&gt;
&nbsp; &lt;/head&gt;
&nbsp; &lt;body&gt;&lt;/body&gt;
&lt;/html&gt;</pre>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{HTMLElement("iframe")}}</li>
 <li><a href="/en-US/docs/Web/Security/Same-origin_policy">Same-origin policy</a></li>
</ul>
Revert to this revision