A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/dom/Document/createEvent below:

createEvent · WebPlatform Docs

createEvent Summary

Creates a DOM event of the specified type. This method is deprecated; use event constructors (CustomEvent) instead.

Method of dom/Documentdom/Document

Syntax
var event = document.createEvent(eventType);
Parameters eventType
Data-type
String

One of the following values. Case is not important.

Return Value

Returns an object of type DOM NodeDOM Node

The created event.

Examples

The following example demonstrates how to create and dispatch a custom event that bubbles and cannot be canceled.

var evt = document.createEvent("Event");
evt.initEvent("custom", true, false);
document.getElementById('target').dispatchEvent(evt);

To respond to the custom event created previously, the following example adds an event handler that interacts with the event by setting a expando property named detail.

function reportEvent(evt) {
    evt.detail = "Success.";
}
var p = document.getElementById('target');
p.addEventListener("custom", reportEvent, false);
Notes

If the event object is to be dispatched with dispatchEvent, the appropriate event initialization method must be called. For example, after creating an event of type UIEvent, call initUIEvent to initialize the event object’s values. **Security Warning: **For security reasons, events generated with createEvent are untrusted and have a isTrusted value of false.

Related specifications
DOM Level 3 Events
Working Draft
Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4