Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-22-2005, 02:18 PM   PM User | #1
Srikanth.S
New Coder

 
Join Date: May 2005
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Srikanth.S is an unknown quantity at this point
Close popup when clicked outside it

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.
__________________
Thanks & Regards,
Srikanth S
Srikanth.S is offline   Reply With Quote
Old 12-22-2005, 09:49 PM   PM User | #2
rlemon
Senior Coder

 
Join Date: Apr 2005
Posts: 1,051
Thanks: 0
Thanked 0 Times in 0 Posts
rlemon is on a distinguished road
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();}
__________________
public string ConjunctionJunction(string words, string phrases, string clauses)
{
return (String)(words + phrases + clauses);
}
<--- Was I Helpfull? Let me know ---<
rlemon is offline   Reply With Quote
Old 12-22-2005, 10:18 PM   PM User | #3
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
You could try something like this
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
function openWin(url){
newwin=window.open(url,'','width=400,height=400');
if(newwin){
window.onfocus=function(){newwin.window.close()}
}
}
</script>
</head>

<body>
<a href="test2.html" onClick="openWin(this.href);return false">Test</a>
</body>
</html>
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.
Code:
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.

Last edited by _Aerospace_Eng_; 12-22-2005 at 10:28 PM..
_Aerospace_Eng_ is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:29 PM.


Advertisement
Log in to turn off these ads.