1

Possible Duplicate:
compute elapsed time in JavaScript

I am trying to construct a lexical decision task for my psychology project.

The task is in javascript: a popup with a word appears and a user clicks yes or no depending on whether the word is grammatical.

I need to count the time between the appearance of the popup and the user click. Could you tell em what needs to be done.

Community
  • 1
  • 1

1 Answers1

3

when the pop-up appears you could store the current time retrieved with this statement:

var createDate = new Date().getTime();

Then when the user click on Yes or No you retrieve the new date and compute the difference with the previous timestamp:

var delay = new Date().getTime() - createDate;
koopajah
  • 23,792
  • 9
  • 78
  • 104