Gecko-Specific DOM Events

  • Revision slug: Gecko-Specific_DOM_Events
  • Revision title: Gecko-Specific DOM Events
  • Revision id: 54406
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment 302 words added

Revision Content

DOMContentLoaded

Fired on a Window object when a document's DOM content is finished loaded, but unlike "load", does not wait till all images are loaded. Used for example by GreaseMonkey to sneak in to alter pages before they are displayed.

This event, as many others on this page, is dispatched to "trusted" targets only; for example, it is not dispatched to the content of the main browser object in Firefox, even if it comes from a chrome:/ URI.

DOMFrameContentLoaded

Same as above, but also fired for enclosed frames.

DOMWindowClose

Fired when the window is about to be closed by window.close(). See

MozAfterPaint

{{ fx_minversion_note("3") }}

The MozAfterPaint event is fired whenever content is repainted.  It is sent to the document and bubbles up to the window level.

MozAfterPaint has two attributes:

  • clientRects
  • boundingClientRect

These tell you what area was repainted, using the same objects and coordinate system as the getClientRects() and getBoundingClientRect() methods.

Important notes

  • MozAfterPaint is a Gecko-only event, and should not be used outside chrome code, such as extensions.
  • For security reasons, regular Web content is only notified of repainting that occurred in its own document.  Repainting caused by iframes is not reported to untrusted listeners.  Listeners added by trusted content, such as extensions or other chrome code, are notified of all repaints.
  • If your event handler does anything that triggers repainting, such as changing the style of an element, you will probably trigger an infinite loop.  So please don't do that.
  • Repainting of areas scrolled outside the viewport is reported, but repainting of areas scrolled outside overflow:auto elements and the like is not.
  • Repainting in windowed plugins (which is most plugins on Windows and GTK) is not reported.

Possible uses

There are several situations in which MozAfterPaint can be useful.  For example, you can use it in an extension that wants to capture the contents of a window using it in tandem with the canvas.drawWindow() method.  You can also use it while testing web content to add JavaScript instrumentation to measure what gets painted by Firefox and when, in order to optimize your site.

Others

There appear to be many other sparsely documented events. See {{ Bug("286013") }}:

  • DOMLinkAdded
  • DOMLinkRemoved
  • DOMWillOpenModalDialog
  • DOMModalDialogClosed
  • DOMWindowClose
  • fullscreen
  • PopupWindow
  • DOMContentLoaded
  • DOMTitleChanged
  • PluginNotFound
  • ValueChange
  • DOMMenuItemActive
  • DOMFrameContentLoaded
  • windowZLevel

Example

window.addEventListener("DOMFrameContentLoaded", myeventhandler, true);

See also

Event Handlers, DOM Events

{{ languages( { "ja": "ja/Gecko-Specific_DOM_Events" } ) }}

Revision Source

<h3 name="DOMContentLoaded">DOMContentLoaded</h3>
<p>Fired on a Window object when a document's DOM content is finished loaded, but unlike "load", does not wait till all images are loaded. Used for example by GreaseMonkey to sneak in to alter pages before they are displayed.</p>
<p>This event, as many others on this page, is dispatched to "trusted" targets only; for example, it is not dispatched to the content of the main browser object in Firefox, even if it comes from a chrome:/ URI.</p>
<h3 name="DOMFrameContentLoaded">DOMFrameContentLoaded</h3>
<p>Same as above, but also fired for enclosed frames.</p>
<h3 name="DOMWindowClose">DOMWindowClose</h3>
<p>Fired when the window is about to be closed by window.close(). See <a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=103452"></a></p>
<h3>MozAfterPaint</h3>
<p>{{ fx_minversion_note("3") }}</p>
<p>The <code>MozAfterPaint </code>event is fired whenever content is repainted.  It is sent to the document and bubbles up to the window level.</p>
<p>MozAfterPaint has two attributes:</p>
<ul> <li><code>clientRects</code></li> <li><code>boundingClientRect</code></li>
</ul>
<p>These tell you what area was repainted, using the same objects and coordinate system as the <a class="internal" href="/En/DOM/Element.getClientRects" title="En/DOM/Element.getClientRects"><code>getClientRects()</code></a> and <a class="internal" href="/En/DOM/Element.getBoundingClientRect" title="En/DOM/Element.getBoundingClientRect"><code>getBoundingClientRect()</code></a> methods.</p>
<h4>Important notes</h4>
<ul> <li><code>MozAfterPaint</code> is a Gecko-only event, and should not be used outside chrome code, such as extensions.</li> <li>For security reasons, regular Web content is only notified of repainting that occurred in its own document.  Repainting caused by iframes is not reported to untrusted listeners.  Listeners added by trusted content, such as extensions or other chrome code, are notified of all repaints.</li> <li>If your event handler does anything that triggers repainting, such as changing the style of an element, you will probably trigger an infinite loop.  So please don't do that.</li> <li>Repainting of areas scrolled outside the viewport is reported, but repainting of areas scrolled outside <code>overflow:auto</code> elements and the like is not.</li> <li>Repainting in windowed plugins (which is most plugins on Windows and GTK) is not reported.</li>
</ul>
<h4>Possible uses</h4>
<p>There are several situations in which MozAfterPaint can be useful.  For example, you can use it in an extension that wants to capture the contents of a window using it in tandem with the <a class="internal" href="/en/Drawing%20Graphics%20with%20Canvas#Rendering_Web_Content_Into_A_Canvas" title="en/Drawing Graphics with Canvas#Rendering Web Content Into A Canvas"><code>canvas.drawWindow()</code></a> method.  You can also use it while testing web content to add JavaScript instrumentation to measure what gets painted by Firefox and when, in order to optimize your site.</p>
<h3 name="Others">Others</h3>
<p>There appear to be many other sparsely documented events. See {{ Bug("286013") }}:</p>
<ul> <li>DOMLinkAdded</li> <li>DOMLinkRemoved</li> <li>DOMWillOpenModalDialog</li> <li>DOMModalDialogClosed</li> <li>DOMWindowClose</li> <li>fullscreen</li> <li>PopupWindow</li> <li>DOMContentLoaded</li> <li>DOMTitleChanged</li> <li>PluginNotFound</li> <li>ValueChange</li> <li>DOMMenuItemActive</li> <li>DOMFrameContentLoaded</li> <li>windowZLevel</li>
</ul>
<h3 name="Example">Example</h3>
<pre class="eval">window.addEventListener("DOMFrameContentLoaded", myeventhandler, true);
</pre>
<h3 name="See_also">See also</h3>
<p><a href="/en/DOM/element#Event_Handlers" title="en/DOM/element#Event_Handlers">Event Handlers</a>, <a href="/en/DOM_Events" title="en/DOM_Events">DOM Events</a></p>

<p>{{ languages( { "ja": "ja/Gecko-Specific_DOM_Events" } ) }}</p>
Revert to this revision