title: Javascript Check if window was opened by script
body: <p>Is it possible to check if script opened a window with Javascript?</p>
  
  <p>I have User agreements and they are opened in new window and this works (when i try to close the window)</p>
  
  <pre><code>&lt;a href="JavaScript:window.close()" class="btn btn-default"&gt;Return&lt;/a&gt;
  </code></pre>
  
  <p>But what i would like to accomplish is that if user go directly to <code>/agreeement</code> and clicks close that it redirects him to the homepage. Because now if i do that i get a message </p>
  
  <blockquote>
    <p>Scripts may close only the windows that were opened by it.</p>
  </blockquote>
  
  <p>And i understand why. That is why i would like to make a check where if the window was not open from a script redirect to index. But i dont how would i make that check</p>