Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

how can i get the time of close the popup window

Posted on 2011-10-31
6
Medium Priority
?
237 Views
Last Modified: 2012-06-27
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 ?
0
Comment
  • 3
  • 2
6 Comments
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 37059812
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
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 37059831
is it for popoup window ?
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 37059862
because i want to restrict the user ,

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

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 83

Expert Comment

by:leakim971
ID: 37059994
>is it for popoup window ?
yes of course, check line 6 : http://www.w3schools.com/jsref/met_win_open.asp
0
 
LVL 18

Expert Comment

by:nap0leon
ID: 37062946
@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
 
LVL 83

Expert Comment

by:leakim971
ID: 37084599
@nap0leon, thanks for your comment
@dravidnsr, thanks for the points

have a good week-end!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question