Trying to close a popup and reload its parent page
<p>Here's my code:</p>

<pre><code>function reloadParentAndClose() {
    window.opener.location.reload();
    window.close();
}
</code></pre>

<p>And here's the error I get:</p>

<blockquote>
  <p>32:132 Uncaught TypeError: Cannot read property 'location' of null(…)</p>
</blockquote>

<p>Any ideas what might be happening?</p>