Raynos
Raynos

Reputation: 169421

Why is event.timeStamp 0 in firefox?

http://jsfiddle.net/wDddR/3/

var input = document.createElement("input");
input.onclick = function (ev) {
    console.log(ev.timeStamp === 0 ? "WHY IS IT ZERO" : "It's not broken");
};
input.click()

var ev = document.createEvent("Event");
console.log(ev.timeStamp === 0 ? "THIS IS MADNESS" : "At least this works");

In firefox the first timeStamp is 0 and in chrome the timestamp is a sensible number.

In both firefox and chrome the second timeStamp is a sensible number.

Upvotes: 1

Views: 1565

Answers (2)

Paul
Paul

Reputation: 141827

The W3C specification states:

Used to specify the time (in milliseconds relative to the epoch) at which the event was created. Due to the fact that some systems may not provide this information the value of timeStamp may be not available for all events. When not available, a value of 0 will be returned.

Upvotes: 0

paulsm4
paulsm4

Reputation: 121699

http://api.jquery.com/event.timeStamp/

Note: Due to a bug open since 2004, this value is not populated correctly in Firefox and it is not possible to know the time the event was created in that browser.

Bug #238041 - nsDOMEvent::AllocateEvent assigns a PR_Now() into a PRUint32

Upvotes: 6

Related Questions