JavaScript事件时间戳不一致 [英] JavaScript event timestamps not consistent

查看:133
本文介绍了JavaScript事件时间戳不一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,当我点击我的网站上的一个元素e.timeStamp由事件处理程序中的Firebug报告为9位数字,如866523917,当我点击不同的元素e.timeStamp报告在该处理程序通过Firebug作为一个16位数的数字,就像
1376344365954000一样。为什么有这个区别?

谢谢

解决方案

timeStamp 返回时间以来的毫秒数量:

< blockquote>

用于指定创建事件的
的时间(相对于纪元的毫秒数)。由于某些系统不能
提供这些信息,因此对于所有事件,timeStamp的值可能不可用
。当不可用时,将返回0值。


然而,对epoch没有严格的定义:


纪元时间的例子是系统开始的时间或1970年1月1日0:0:0 UTC

有些事件使用第一个变量(系统启动),而其他事件使用自1970年以来的时间。作为一个方面说明,可能有一些事件并没有提供 timeStamp ,那么它的值将是 0

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

解决方案

As 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.

这篇关于JavaScript事件时间戳不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆