小码哥的IT人生

XML DOM timeStamp 事件属性

XML基础 2023-08-13 19:20:55小码哥的IT人生shichen

XML DOM timeStamp 事件属性

定义和用法

timeStamp 事件属性可返回一个时间戳。指示发生事件的日期和时间(从 epoch 开始的毫秒数)。

epoch 是一个事件参考点。在这里,它是客户机启动的时间。

并非所有系统都提供该信息,因此,timeStamp 属性并非对所有系统/事件都是可用的。

语法

event.timeStamp

实例

下面的例子可获得系统启动开始的事件戳:

<html>
<head>
<script type="text/javascript">
function showTimestamp(event)
  {
  var minutes = 1000*60
  x=event.timeStamp;
  alert(x/minutes)
  }
</script>
</head>
<body onmousedown="showTimestamp(event)">
<p>Click in the document. An alert
box will alert the timestamp.</p>
</body>
</html>

TIY

完整实例【timestamp event】:

<html>
<head>
<script type="text/javascript">
function showTimestamp(event)
  {
  var minutes = 1000*60
  x=event.timeStamp;
  alert(x/minutes)
  }
</script>
</head>
<body onmousedown="showTimestamp(event)">
<p>Click in the document. An alert box will alert the timestamp.</p>
</body>
</html>

可以使用本站在线JavaScript测试工具测试上述代码运行效果:http://www.phpcodeweb.com/runjs.html

返回系统启动至今的分钟数(IE 浏览器不支持)。

版权所有 © 小码哥的IT人生
Copyright © phpcodeweb All Rights Reserved
ICP备案号:苏ICP备17019232号-2  

苏公网安备 32030202000762号

© 2021-2024