aboutsummaryrefslogtreecommitdiff
path: root/files/uk/web/api/customevent/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:43:23 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:43:23 -0500
commit218934fa2ed1c702a6d3923d2aa2cc6b43c48684 (patch)
treea9ef8ac1e1b8fe4207b6d64d3841bfb8990b6fd0 /files/uk/web/api/customevent/index.html
parent074785cea106179cb3305637055ab0a009ca74f2 (diff)
downloadtranslated-content-218934fa2ed1c702a6d3923d2aa2cc6b43c48684.tar.gz
translated-content-218934fa2ed1c702a6d3923d2aa2cc6b43c48684.tar.bz2
translated-content-218934fa2ed1c702a6d3923d2aa2cc6b43c48684.zip
initial commit
Diffstat (limited to 'files/uk/web/api/customevent/index.html')
-rw-r--r--files/uk/web/api/customevent/index.html96
1 files changed, 96 insertions, 0 deletions
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
+---
+<p>{{APIRef("DOM")}} Інтерфейс <strong><code>CustomEvent</code></strong> являє собою події, ініціалізовані додатком для будь-яких цілей.</p>
+
+<p>{{AvailableInWorkers}}</p>
+
+<h2 id="Конструктор">Конструктор</h2>
+
+<dl>
+ <dt>{{domxref("CustomEvent.CustomEvent", "CustomEvent()")}}</dt>
+ <dd>Створює <code>CustomEvent</code>.</dd>
+</dl>
+
+<h2 id="Властивості">Властивості</h2>
+
+<dl>
+ <dt>{{domxref("CustomEvent.detail")}} {{readonlyinline}}</dt>
+ <dd>Будь-які дані, передані при ініціалізації події.</dd>
+</dl>
+
+<p><em>Цей інтерфейс успадковує властивості від батьків, </em>{{domxref("Event")}}:</p>
+
+<p>{{Page("/en-US/docs/Web/API/Event", "Properties")}}</p>
+
+<h2 id="Методи">Методи</h2>
+
+<dl>
+ <dt>{{domxref("CustomEvent.initCustomEvent()")}} {{deprecated_inline}}</dt>
+ <dd>
+ <p><code><font face="Open Sans, arial, x-locale-body, sans-serif"><span style="background-color: #ffffff;">Ініціалізує об'єкт </span></font>CustomEvent</code>. Якщо подія вже відправлена, цей метод нічого не робить.</p>
+ </dd>
+</dl>
+
+<p><em>Цей інтерфейс успадковує властивості від батьків, </em>{{domxref("Event")}}:</p>
+
+<p>{{Page("/en-US/docs/Web/API/Event", "Methods")}}</p>
+
+<h2 id="Специфікації">Специфікації</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Специфікація</th>
+ <th scope="col">Статус</th>
+ <th scope="col">Комертарі</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('DOM WHATWG','#interface-customevent','CustomEvent')}}</td>
+ <td>{{Spec2('DOM WHATWG')}}</td>
+ <td>Початкове визначення.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Браузерна_сумісність">Браузерна сумісність</h2>
+
+
+
+<p>{{Compat("api.CustomEvent")}}</p>
+
+<h2 id="Firing_from_privileged_code_to_non-privileged_code">Firing from privileged code to non-privileged code</h2>
+
+<p>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.</p>
+
+<p>While creating a CustomEvent object, you must create the object from the same <a href="/en-US/docs/XUL/window">window</a>. The <code>detail</code> 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 <a href="/en-US/docs/">Components.utils.cloneInto()</a>.</p>
+
+<pre class="brush: js">// 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);
+}</pre>
+
+<p>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.</p>
+
+<h2 id="Дивіться_також">Дивіться також</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Code_snippets/Interaction_between_privileged_and_non-privileged_pages" title="/en-US/docs/Code_snippets/Interaction_between_privileged_and_non-privileged_pages">Interaction between privileged and non-privileged pages</a></li>
+ <li><a href="/en-US/docs/Web/API/window.postMessage" title="/en-US/docs/Web/API/window.postMessage">Window.postMessage</a></li>
+ <li><a href="/en-US/docs/Web/Guide/Events/Creating_and_triggering_events">Creating and triggering events</a></li>
+</ul>