• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • Last Modified:

how to calculate popup window timing

HI ,

I have  course link , if i press any course then one popup will open , that time i want to calculate the timing how much time the popup window is open ?  how to do that ??
0
Sathish David  Kumar N
Asked:
Sathish David  Kumar N
  • 3
  • 3
1 Solution
 
BardobraveCommented:
You could try to launch a function when opening the popup through a setInterval of 1 milisecond. That function will check if the popup window exists and, if it isn't, increase a miliseconds counter.

Problems with this idea:
-Executing a function each milisecond, although a simple one like this, is not a good idea for performance.
-Also the execution of the own function will delay the counter, under client computer load maybe even one call to the function may arise before the last one finishes.

I don't understand why do you want to control this. A pop-up opening will be always called in the less time possible and it will be dependant on the client machine load and capabilities, so seems quite pointless to me to measure this time.
0
 
Easwaran ParamasivamCommented:
Have var starttime and endtime globally declared.

In the document.onload method set the current time to starttime.

In the window.onbeforeunload method have a function. In that function set the current time to endtime. Find the time difference (endtime - starttime). This is the duration to calculate the open time of the window.



0
 
Sathish David Kumar NAuthor Commented:
Can ypu give some sample code??
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Easwaran ParamasivamCommented:
At start of your <script> tag

 var startdate, enddate;

document.onload = loadfunction();
window.onbeforeunload = unloadme();

function loadfunction()
{
startdate = new Date();
}

function unloadme()
{
 enddate= new Date();

 //calculate difference b/w enddate and startdate. Refer the below link for that.

}

http://blog.stephenrushing.com/index.php/javascript/javascript-date-difference-as-milliseconds-minutes-hours-days-weeks-months-or-years/
0
 
Sathish David Kumar NAuthor Commented:
@EaswaranP: i am asking for popup winodow time calulcation

The Main in the question is

1. Calculate time how much time the popup is open ?
0
 
Easwaran ParamasivamCommented:
Thats what my answer for. Have you tried that? What are you getting?
0
 
Sathish David Kumar NAuthor Commented:
Not get full solution
0

Featured Post

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!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now