how can we do popup background disable when we click on anywhere in the relevent page
<p>i have a button when i click on it i show a popup with disable background but if  i click on anywhere in the page except popup it is not enabling</p>

<pre><code>&lt;a href="#" onClick="pop('popDiv')"&gt;Click here to open a popup div&lt;/a&gt;

&lt;a href="#" onClick="hide('popDiv')"&gt;Close&lt;/a&gt;

&lt;script type="text/javascript"&gt;
function pop(div) {
    document.getElementById(div).style.display = 'block';
}
function hide(div) {
    document.getElementById(div).style.display = 'none';
}
//To detect escape button
document.onkeydown = function(evt) {
    evt = evt || window.event;
    if (evt.keyCode == 27) {
        hide('popDiv');
    }
};
&lt;/script&gt;
</code></pre>