By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,713 Members | 1,326 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,713 IT Pros & Developers. It's quick & easy.

Avoiding closing Parent window before child close Javascript.

P: 25
I have a problem, I have Javascript that opens a popup. I want to avoide the user from closing the parent window first. I dont want to use showDialog, I want to use window.open() only.. Is there any way to do that..? I already came to extent so i can able to give a prompt to user saying that Please close the child first.. But i am not able to control the flow. meaning it shows the message and close the window. Please help me over come this problem.

Thanks a lot
-Ashwath
May 30 '07 #1
Share this Question
Share on Google+
3 Replies


100+
P: 428
It would be friendlier to close the popup from the parent window's onunload handler. Never argue with your visitors...
May 30 '07 #2

P: 25
It would be friendlier to close the popup from the parent window's onunload handler. Never argue with your visitors...
Hi ,
thanks for your valuable suggestion. Can you please explain me what i want to wirte in onunload Event.. I tried to write a code there also. but no luck. :(

Thanks in adavance..!

-Ashwath
May 31 '07 #3

pbmods
Expert 5K+
P: 5,821
thanks for your valuable suggestion. Can you please explain me what i want to wirte in onunload Event.. I tried to write a code there also. but no luck. :(
When you open the new window, save the reference into a variable, then set window.onload to call the new window's close method, like this:

Expand|Select|Wrap|Line Numbers
  1. var childWindow = window.open(...);
  2.  
  3. window.onunload = childWindow.close;
  4.  
May 31 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.