0

I have following link in my frame, this will open as new window, I want to know the open window is close or not, because I need to clear a cookie when user close the window.

<a href="http://stackoverflow.com/questions/ask" target="_blank">study plan new wndow</a>
5
  • 1
    Is that the real link ? i.e. Are you opening a page you own/control/can modify or is the link pointing to the outside world ? Commented Mar 5, 2014 at 10:56
  • no, real link is same domain with frame set Commented Mar 5, 2014 at 10:58
  • This link is SSO logging link, its redirect to some 3rd party page Commented Mar 5, 2014 at 10:59
  • Do you want to be able to tell if the window is still open, or do you want to react when it is closed? They're two very different things. Commented Mar 5, 2014 at 10:59
  • That changes the potential answers, you should include the real code Commented Mar 5, 2014 at 10:59

2 Answers 2

1

html:

<a href="#" onclick="myWinOpen(); return false;">study plan new wndow</a>

JS:

function myWinOpen()
{
    var w = window.open('http://same-domain.com/page.html');
    w.onbeforeunload = function()
    { 
        // my code..
    }
}
Sign up to request clarification or add additional context in comments.

1 Comment

NOTE: popup url must be in the same domain of the parent
0
window.onunload=function(){/*SomeJavaScriptCode*/};

OR

window.onbeforeunload = function (){/*your Cookie clear code here*/}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.