Inside the pop-up window, you can use the unloadobject's event windowto detect that the window has closed or go to a new page by pre-registering the time it opened at the top of the document. For instance:
<html>
<head>
<script type="text/javascript">
var start = new Date();
window.onunload = function() {
var end = new Date();
var secondsOpen = Math.floor((end - start) / 1000);
alert("Pop-up was open for " + secondsOpen + " seconds");
};
</script>
</head>
<body>
...
</body>
</html>
source
share