From 074785cea106179cb3305637055ab0a009ca74f2 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:52 -0500 Subject: initial commit --- files/ru/web/api/event/timestamp/index.html | 103 ++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 files/ru/web/api/event/timestamp/index.html (limited to 'files/ru/web/api/event/timestamp/index.html') diff --git a/files/ru/web/api/event/timestamp/index.html b/files/ru/web/api/event/timestamp/index.html new file mode 100644 index 0000000000..6a79557c96 --- /dev/null +++ b/files/ru/web/api/event/timestamp/index.html @@ -0,0 +1,103 @@ +--- +title: Event.timeStamp +slug: Web/API/Event/timeStamp +translation_of: Web/API/Event/timeStamp +--- +
{{APIRef("DOM")}}
+ +

Возвращает время (в миллисекундах), в котором было создано событие.

+ +
+

Примечание: Это свойство работает только в том случае, если система событий поддерживает его для конкретного события.

+
+ +

Синтаксис

+ +
event.timeStamp
+
+ +

Значение

+ +

Значение - это миллисекунды, прошедшие с начала жизненного цикла текущего документа до создания события.

+ +

In newer implementations, the value is a {{domxref("DOMHighResTimeStamp")}}  accurate to 5 microseconds (0.005 ms). In older implementations, the value is a {{domxref("DOMTimeStamp")}}, accurate to a millisecond.

+ +

Example

+ +

HTML content

+ +
<p>
+  Focus this iframe and press any key to get the
+  current timestamp for the keypress event.
+</p>
+<p>timeStamp: <span id="time">-</span></p>
+ +

JavaScript content

+ +
function getTime(event) {
+  var time = document.getElementById("time");
+  time.firstChild.nodeValue = event.timeStamp;
+}
+document.body.addEventListener("keypress", getTime);
+ +

Result

+ +

{{EmbedLiveSample("Example", "100%", 100)}}

+ +

Reduced time precision

+ +

To offer protection against timing attacks and fingerprinting, the precision of event.timeStamp might get rounded depending on browser settings.
+ In Firefox, the privacy.reduceTimerPrecision  preference is enabled by default and defaults to 20us in Firefox 59; in 60 it will be 2ms.

+ +
// reduced time precision (2ms) in Firefox 60
+event.timeStamp;
+// 1519211809934
+// 1519211810362
+// 1519211811670
+// ...
+
+
+// reduced time precision with `privacy.resistFingerprinting` enabled
+event.timeStamp;
+// 1519129853500
+// 1519129858900
+// 1519129864400
+// ...
+
+ +

In Firefox, you can also enabled privacy.resistFingerprinting, the precision will be 100ms or the value of privacy.resistFingerprinting.reduceTimerPrecision.microseconds, whichever is larger.

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("DOM WHATWG", "#dom-event-timestamp", "Event.timeStamp")}}{{Spec2("DOM WHATWG")}} 
{{SpecName("DOM4", "#dom-event-timestamp", "Event.timeStamp")}}{{Spec2("DOM4")}} 
{{SpecName("DOM2 Events", "#Events-Event-timeStamp", "Event.timeStamp")}}{{Spec2("DOM2 Events")}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.Event.timeStamp")}}

-- cgit v1.2.3-54-g00ecf