title: Closing Modal Popup by Clicking Away from It
body: <p>I am using this tutorial to add a modal screen:</p>
  
  <p><a href="http://raventools.com/blog/create-a-modal-dialog-using-css-and-javascript/" rel="nofollow">http://raventools.com/blog/create-a-modal-dialog-using-css-and-javascript/</a></p>
  
  <p>Everything works great except closing it. Rather than closing it via a button, I want to give the user the option to close it by clicking outside of the modal, i.e. in the background of the rest of the page behind it. </p>
  
  <p>A user told me to add <code>onclick='overlay()'</code> to the overlay div like this <code>&lt;div id="overlay" onclick='overlay()'&gt;</code></p>
  
  <p>When I try to close the modal by clicking outside if it, it works, but it also closes if you click on the actual modal itself, which I don't want as it is a registration form. So is there any way to only close the modal by clicking outside of the actual modal itself?</p>