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?
 
leakim971PluritechnicianCommented:
test page : http://jsfiddle.net/afPFW/

<a href="#" onclick="openIt('http://www.google.com')">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) {
            clearInterval(t);
            e = new Date().getTime();
            alert("number of seconds : " + (e-s)/1000 );
        }
    }, 250);
}

Open in new window

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

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

0
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.

 
leakim971PluritechnicianCommented:
>is it for popoup window ?
yes of course, check line 6 : http://www.w3schools.com/jsref/met_win_open.asp
0
 
nap0leonCommented:
@leakim971
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).
0
 
leakim971PluritechnicianCommented:
@nap0leon, thanks for your comment
@dravidnsr, thanks for the points

have a good week-end!
0
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.