Class EventTarget
java.lang.Object
org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.javascript.HtmlUnitScriptable
org.htmlunit.javascript.host.event.EventTarget
- All Implemented Interfaces:
Serializable,Cloneable,org.htmlunit.corejs.javascript.ConstProperties,org.htmlunit.corejs.javascript.debug.DebuggableObject,org.htmlunit.corejs.javascript.Scriptable,org.htmlunit.corejs.javascript.SymbolScriptable
- Direct Known Subclasses:
Animation,AudioNode,BaseAudioContext,BatteryManager,BroadcastChannel,DedicatedWorkerGlobalScope,DOMRequest,EventSource,FileReader,FontFaceSet,IDBDatabase,IDBRequest,IDBTransaction,MediaDevices,MediaKeySession,MediaQueryList,MediaRecorder,MediaSource,MediaStream,MediaStreamTrack,MessagePort,MIDIAccess,MIDIPort,NetworkInformation,Node,Notification,PaymentRequest,PaymentResponse,Performance,PermissionStatus,PresentationAvailability,PresentationConnection,PresentationRequest,RemotePlayback,RTCPeerConnection,RTCSctpTransport,Screen,ScreenOrientation,ServiceWorker,ServiceWorkerContainer,ServiceWorkerRegistration,SharedWorker,SourceBuffer,SourceBufferList,SpeechSynthesis,SpeechSynthesisUtterance,TextTrack,TextTrackCue,TextTrackList,WebkitSpeechRecognition,WebSocket,Window,Worker,XMLHttpRequestEventTarget
A JavaScript object for
EventTarget.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator -
Field Summary
FieldsFields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONSTFields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEventListener(String type, org.htmlunit.corejs.javascript.Scriptable listener, boolean useCapture) Allows the registration of event listeners on the event target.protected voidClears the event listener container.booleandispatchEvent(Event event) Dispatches an event into the event system (standards-conformant browsers only).voidexecuteEventLocally(Event event) Executes the event on this object only (needed for instance for onload on (i)frame tags).Fires the event on the node with capturing and bubbling phase.org.htmlunit.corejs.javascript.FunctiongetEventHandler(String eventType) Returns the specified event handler.final EventListenersContainerGets the container for event listeners.booleanhasEventHandlers(String eventName) Returnstrueif there are any event handlers for the specified event.protected booleanIs setting event handler property, at window-level.voidJavaScript constructor.voidremoveEventListener(String type, org.htmlunit.corejs.javascript.Scriptable listener, boolean useCapture) Allows the removal of event listeners on the event target.voidsetEventHandler(String eventName, Object value) Defines an event handler (or maybe any other object).Methods inherited from class org.htmlunit.javascript.HtmlUnitScriptable
clone, equivalentValues, get, getBrowserVersion, getClassName, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getWindow, getWindow, getWithPreemption, has, hasInstance, initParentScope, makeScriptableFor, put, setClassName, setDomNode, setDomNode, setParentScope, setupPromise, setupRejectedPromiseMethods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setPrototype, size
-
Field Details
-
eventListenersContainer_
-
-
Constructor Details
-
EventTarget
public EventTarget()Default constructor.
-
-
Method Details
-
jsConstructor
public void jsConstructor()JavaScript constructor. -
addEventListener
public void addEventListener(String type, org.htmlunit.corejs.javascript.Scriptable listener, boolean useCapture) Allows the registration of event listeners on the event target.- Parameters:
type- the event type to listen for (like "click")listener- the event listeneruseCapture- Iftrue, indicates that the user wishes to initiate capture- See Also:
-
getEventListenersContainer
Gets the container for event listeners.- Returns:
- the container (newly created if needed)
-
executeEventLocally
Executes the event on this object only (needed for instance for onload on (i)frame tags).- Parameters:
event- the event- See Also:
-
fireEvent
Fires the event on the node with capturing and bubbling phase.- Parameters:
event- the event- Returns:
- the result
-
hasEventHandlers
Returnstrueif there are any event handlers for the specified event.- Parameters:
eventName- the event name (e.g. "onclick")- Returns:
trueif there are any event handlers for the specified event,falseotherwise
-
getEventHandler
Returns the specified event handler.- Parameters:
eventType- the event type (e.g. "click")- Returns:
- the handler function, or
nullif the property is null or not a function
-
dispatchEvent
Dispatches an event into the event system (standards-conformant browsers only). See the Gecko DOM reference for more information.- Parameters:
event- the event to be dispatched- Returns:
falseif at least one of the event handlers which handled the event calledpreventDefault;trueotherwise
-
removeEventListener
public void removeEventListener(String type, org.htmlunit.corejs.javascript.Scriptable listener, boolean useCapture) Allows the removal of event listeners on the event target.- Parameters:
type- the event type to listen for (like "click")listener- the event listeneruseCapture- Iftrue, indicates that the user wishes to initiate capture (not yet implemented)- See Also:
-
setEventHandler
Defines an event handler (or maybe any other object).- Parameters:
eventName- the event name (e.g. "click")value- the property (nullto reset it)
-
isEventHandlerOnWindow
protected boolean isEventHandlerOnWindow()Is setting event handler property, at window-level.- Returns:
- whether the event handler to be set at window-level
-
clearEventListenersContainer
protected void clearEventListenersContainer()Clears the event listener container.
-