From 218934fa2ed1c702a6d3923d2aa2cc6b43c48684 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:43:23 -0500 Subject: initial commit --- files/uk/web/api/customevent/index.html | 96 +++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 files/uk/web/api/customevent/index.html (limited to 'files/uk/web/api/customevent/index.html') diff --git a/files/uk/web/api/customevent/index.html b/files/uk/web/api/customevent/index.html new file mode 100644 index 0000000000..76b8aeef1a --- /dev/null +++ b/files/uk/web/api/customevent/index.html @@ -0,0 +1,96 @@ +--- +title: CustomEvent +slug: Web/API/CustomEvent +tags: + - API + - DOM + - Interface + - NeedsCompatTable + - NeedsExample + - NeedsTranslation + - Reference + - TopicStub +translation_of: Web/API/CustomEvent +--- +

{{APIRef("DOM")}} Інтерфейс CustomEvent являє собою події, ініціалізовані додатком для будь-яких цілей.

+ +

{{AvailableInWorkers}}

+ +

Конструктор

+ +
+
{{domxref("CustomEvent.CustomEvent", "CustomEvent()")}}
+
Створює CustomEvent.
+
+ +

Властивості

+ +
+
{{domxref("CustomEvent.detail")}} {{readonlyinline}}
+
Будь-які дані, передані при ініціалізації події.
+
+ +

Цей інтерфейс успадковує властивості від батьків, {{domxref("Event")}}:

+ +

{{Page("/en-US/docs/Web/API/Event", "Properties")}}

+ +

Методи

+ +
+
{{domxref("CustomEvent.initCustomEvent()")}} {{deprecated_inline}}
+
+

Ініціалізує об'єкт CustomEvent. Якщо подія вже відправлена, цей метод нічого не робить.

+
+
+ +

Цей інтерфейс успадковує властивості від батьків, {{domxref("Event")}}:

+ +

{{Page("/en-US/docs/Web/API/Event", "Methods")}}

+ +

Специфікації

+ + + + + + + + + + + + + + + + +
СпецифікаціяСтатусКомертарі
{{SpecName('DOM WHATWG','#interface-customevent','CustomEvent')}}{{Spec2('DOM WHATWG')}}Початкове визначення.
+ +

Браузерна сумісність

+ + + +

{{Compat("api.CustomEvent")}}

+ +

Firing from privileged code to non-privileged code

+ +

When firing a CustomEvent from privileged code (i.e. an extension) to non-privileged code (i.e. a webpage), security issues should be considered. Firefox and other Gecko applications restrict an object created in one context from being directly used for another, which will automatically prevent security holes, but these restrictions may also prevent your code from running as expected.

+ +

While creating a CustomEvent object, you must create the object from the same window. The detail attribute of your CustomEvent will be subjected to the same restrictions. String and Array values will be readable by the content without restrictions, but custom Objects will not. While using a custom Object, you will need to define the attributes of that object that are readable from the content script using Components.utils.cloneInto().

+ +
// doc is a reference to the content document
+function dispatchCustomEvent(doc) {
+  var eventDetail = Components.utils.cloneInto({foo: 'bar'}, doc.defaultView);
+  var myEvent = doc.defaultView.CustomEvent("mytype", eventDetail);
+  doc.dispatchEvent(myEvent);
+}
+ +

But one needs to keep in mind that exposing a function will allow the content script to run it with chrome privileges, which can open a security vulnerability.

+ +

Дивіться також

+ + -- cgit v1.2.3-54-g00ecf