View Full Version : Close popup when clicked outside it

12-22-2005, 02:18 PM
Hi All,
I have a popup window in my site which has form elements in it,I need to close that popup when the user clicks some where outside it or i should restrict the users to do nothing with the parent window when the popup is opened.But it has to be opened when clicking on it and while filling the form elements in it.I already tried <body OnBlur="window.close"> but it's closing the window even i clicked inside the popup.I need a solution to handle this situation.

12-22-2005, 09:49 PM
yea i can't figure it out right now - i'll try some more later - i've been attempting to hack in document.body.onbeforefocusleave=function(){window.close();}

12-22-2005, 10:18 PM
You could try something like this

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
function openWin(url){

<a href="test2.html" onClick="openWin(this.href);return false">Test</a>

Where test2.html is your popup obviously. If its open and focus is set to the parent window the popup will close.
That would go in the head tags of the parent page. Hmm an error is thrown when the user goes from a normal application like MS Word and back to the page.

The callee (server [not server application]) is not available and disappeared; all connections are invalid. The call did not execute.
This may only happen locally, I'll upload the test files to my server and check. Yeah that happens on my server as well, only in IE though.:confused: