admin管理员组文章数量:1391975
I notice that when I click one element on my site e.timeStamp is reported by Firebug in the event handler as a 9-digit number, like 866523917, and when I click a different element e.timeStamp is reported in that handler by Firebug as a 16-digit number, like 1376344365954000. Why the difference?
Thanks
I notice that when I click one element on my site e.timeStamp is reported by Firebug in the event handler as a 9-digit number, like 866523917, and when I click a different element e.timeStamp is reported in that handler by Firebug as a 16-digit number, like 1376344365954000. Why the difference?
Thanks
Share Improve this question edited Aug 13, 2013 at 3:10 user663031 asked Aug 12, 2013 at 22:02 SteveSteve 4,92811 gold badges60 silver badges117 bronze badges 6- 1 what do you mean by: when i click? who fires the event? please provide a live demo illustrating this or otherwise elaborate on the issue. – Eliran Malka Commented Aug 12, 2013 at 22:07
-
Sounds interesting.
event.timeStamp
is the number of milliseconds (since the epoch) at which the event was created. There shouldn't be such a big difference. Can you present a sample code? – ntalbs Commented Aug 12, 2013 at 22:53 - Here's a demo - jsfiddle/stevea/zTm9L/1. The 1376344365954000 is the right number, since that breaks down to 43 years. But for some reason, the one above is ing in around 877246085. These are ms, since it changes about 1000 per second, so the number is about 240 hours. – Steve Commented Aug 13, 2013 at 0:50
- What do you mean by "the one above"? There is only one button I can se e in the fiddle. – user663031 Commented Aug 13, 2013 at 3:03
- 1 See bugzilla.mozilla/show_bug.cgi?id=238041. – user663031 Commented Aug 13, 2013 at 3:11
3 Answers
Reset to default 5As defined in standard timeStamp
returns number of milliseconds since epoch:
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.
However, there is no strict definition for epoch:
Examples of epoch time are the time of the system start or 0:0:0 UTC 1st January 1970.
Some events are using first variant (system start) while others use time since 1970. Hence the difference. As a side note it's possible that timeStamp
is not provided at all for some events, then its value will be 0
.
I think the problem is Firefox. I get the larger number (13 digits plus 3 zeroes) on Safari and Chrome, I came across some articles that say Firefox has a bug: http://bugs.jquery./ticket/10755. One article suggested it might be reporting the time since the last reboot.
I still don't understand why Firefox would report it one way for one interrupt and another way for another interrupt. For my purposes I'll just use timestamp=Date.now() instead of e.timestamp. That seems to be consistent at any interrupt.
Instead event.timestamp
, use Date.now()
本文标签: firefoxJavaScript event timestamps not consistentStack Overflow
版权声明:本文标题:firefox - JavaScript event timestamps not consistent - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744679432a2619310.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论