Get the number of milliseconds since this document was loaded.
var n = event.timeStamp;
Click the button to get the number of milliseconds from this document was loaded until the button was clicked.
<!DOCTYPE html> <html> <body> <button onclick="myFunction(event)">Click me!</button> <p>Time since this document was loaded: <span id="demo"></span></p> <script> function myFunction(event) {/* w ww . j a v a 2s.c o m*/ var n = event.timeStamp; document.getElementById("demo").innerHTML = n; } </script> </body> </html>
The timeStamp event property returns the number of milliseconds from the document was finished loading until the specific event was created.
timeStamp may be not available for all systems/events.