Link to home
Start Free TrialLog in
Avatar of Sathish David  Kumar N
Sathish David Kumar NFlag for India

asked on

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 ??
Avatar of Bardobrave
Bardobrave
Flag of Spain image

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.
Avatar of Easwaran Paramasivam
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.



Avatar of Sathish David  Kumar N

ASKER

Can ypu give some sample code??
ASKER CERTIFIED SOLUTION
Avatar of Easwaran Paramasivam
Easwaran Paramasivam
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@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 ?
Thats what my answer for. Have you tried that? What are you getting?
Not get full solution