10 examples of 'iframe event listener' in JavaScript

Every line of 'iframe event listener' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
12addEventListener(handler) {
13 this.Sender.addEventListener('message', handler)
14}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

68detachEventListeners() {
69 this.el.removeEventListener('error', this.onError);
70 this.el.removeEventListener('unhandledrejection', this.onUnhandledRejection);
71}
30stopListen(): void {
31 if (!this._isListening) {
32 return;
33 }
34
35 this._isListening = false;
36
37 window.removeEventListener('message', this._handleMessage);
38}
100_onMessageReceived(event) {
101 const {data, origin} = event;
102 this._iframeOrigin = origin;
103 switch (data.type) {
104 case IFRAME_CONNECTED_EVENT:
105 this.$.iframe.contentWindow.postMessage({
106 type: PARENT_CONNECTED_EVENT,
107 value: null,
108 }, origin);
109 this._sendNamespaceMessage();
110 break;
111 }
112}
78private _emitEvents (iframe: HTMLIFrameElement | HTMLFrameElement): void {
79 // NOTE: Raise this internal event to eval the Hammerhead code script.
80 this.emit(this.EVAL_HAMMERHEAD_SCRIPT_EVENT, { iframe });
81
82 // NOTE: Raise this event to eval external code script.
83 this.emit(this.EVAL_EXTERNAL_SCRIPT_EVENT, { iframe });
84
85 // NOTE: Raise this event to eval the "task" script and to call the Hammerhead initialization method
86 // and external script initialization code.
87 this.emit(this.RUN_TASK_SCRIPT_EVENT, iframe);
88}
50function addIFrameMessageListener(eventType) {
51 this._listenTo.addEventListener(eventType, this, false);
52}
536function registerFrameListener(browser)
537{
538 if (browser.frameListener)
539 return;
540
541 browser.frameListener = FrameProgressListener; // just a mark saying we've registered. TODO remove!
542 browser.addProgressListener(FrameProgressListener, NOTIFY_STATE_DOCUMENT);
543
544}
112function DOMContentLoadedHandler(event) {
113 var doc = event.originalTarget;
114
115 var errorRegex = /about:.+(error)|(blocked)\?/;
116 if (errorRegex.exec(doc.baseURI)) {
117 // Wait about 1s to be sure the DOM is ready
118 mozmill.utils.sleep(1000);
119
120 // Only update the flag if we have a document as target
121 if ("defaultView" in doc) {
122 doc.defaultView.mozmillDocumentLoaded = true;
123 }
124
125 // We need to add/remove the unload event listener to preserve caching.
126 aWindow.gBrowser.addEventListener("beforeunload", beforeUnloadHandler, true);
127 }
128};
91handleEvent: function IE_handleEvent(event) {
92 switch (event.type) {
93 case "DOMNodeInserted":
94 if ("isPage" in this.site.data &&
95 !this.site.query("isPage", event.target, Boolean))
96 break;
97 // fall through
98 case "HB.PageInserted":
99 this.embed();
100 break;
101
102 case "GM_AutoPagerizeLoaded":
103 this.doc.addEventListener("DOMNodeInserted", this, false);
104 break;
105 }
106}
23window.addEventListener('load', function onLoad(aEvent) {
24 window.removeEventListener(aEvent.type, onLoad, false);
25 ReferenceCounter.remove('window,aEvent.type,onLoad,false');
26 if (SSWindowStateBusyListener) {
27 window.removeEventListener('SSWindowStateBusy', SSWindowStateBusyListener, false);
28 ReferenceCounter.remove('window,SSWindowStateBusy,SSWindowStateBusyListener,false');
29 SSWindowStateBusyListener = undefined;
30 }
31 if (SSWindowStateReadyListener) {
32 window.removeEventListener('SSWindowStateReady', SSWindowStateReadyListener, false);
33 ReferenceCounter.remove('window,SSWindowStateReady,SSWindowStateReadyListener,false');
34 SSWindowStateReadyListener = undefined;
35 }
36}, false);

Related snippets