Avoiding closing Parent window before child close Javascript.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • guest
    New Member
    • May 2006
    • 25

    Avoiding closing Parent window before child close Javascript.

    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
  • mrhoo
    Contributor
    • Jun 2006
    • 428

    #2
    It would be friendlier to close the popup from the parent window's onunload handler. Never argue with your visitors...

    Comment

    • guest
      New Member
      • May 2006
      • 25

      #3
      Originally posted by mrhoo
      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

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Originally posted by guest
        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:

        [code=javascript]
        var childWindow = window.open(... );

        window.onunload = childWindow.clo se;
        [/code]

        Comment

        Working...