how can i get the time of close the popup window

how can we calulate popup window how much time its open ?

i have link in my jsp page when i click one popup window will open.

1. that time i will get the start time .
2. when user click browser close button then how can i get the time of close the popup window ?
LVL 20
Sathish David  Kumar NArchitectAsked:
Who is Participating?
test page :

<a href="#" onclick="openIt('')">Open it</a>
var w = null;
var t = null;
var s = null;
var e = null;
function openIt(url) {
    w = open(url);
    s = new Date().getTime();
    t = setInterval(function() { 
        if(w!=null && w.closed) {
            e = new Date().getTime();
            alert("number of seconds : " + (e-s)/1000 );
    }, 250);

Open in new window

Sathish David Kumar NArchitectAuthor Commented:
is it for popoup window ?
Sathish David Kumar NArchitectAuthor Commented:
because i want to restrict the user ,

if popup window open then user dont work in parent window .

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

>is it for popoup window ?
yes of course, check line 6 :
genius idea to assign a variable to the open command.  I've always tried to send a signal back to the parent and had incredibly poor results (sometimes works, sometimes doesn't).
@nap0leon, thanks for your comment
@dravidnsr, thanks for the points

have a good week-end!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.