title: How can I check If I have access to window.opener?
body: <p>How can I check if I have access to window.opener?</p>
  
  <p>I'm getting an error if I open my page in a new window from a file that is not connected with my page (<code>access denied</code>).</p>
  
  <p>Code:</p>
  
  <pre><code>if (window.opener) {
          if (window.opener.document.getElementById('myHidden') !== "undefined") {
              if (window.opener.document.getElementById('myHidden').value == "1" &amp;&amp; $("#inputXYZ").val() != "1") {
  </code></pre>
  
  <p>In line <strong>2</strong> the error occurs. But only if I open the page from a random page (that of course does not have an input field called "myHidden").
  If I open the page from a "valid" page that has such an element, it is working.</p>