HTMLBodyElement

  • Revision slug: DOM/HTMLBodyElement
  • Revision title: HTMLBodyElement
  • Revision id: 286864
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment update for bug 635194; 42 words added, 8 words removed

Revision Content

{{ DomRef() }}

HTML body element interface

DOM body elements expose the HTMLBodyElement (or {{ HTMLVersionInline("4") }} HTMLBodyElement) interface, which provides special properties (beyond the regular {{ domxref("element") }} object interface they also have available to them by inheritance) for manipulating body elements.

Properties

Name Type Description
aLink {{ deprecatedGeneric("inline","html4.01") }}, {{ obsoleteGeneric("inline","html5") }} {{ domxref("DOMString") }} Color of active hyperlinks.
background {{ deprecatedGeneric("inline","html4.01") }}, {{ obsoleteGeneric("inline","html5") }} {{ domxref("DOMString") }}

URI for a background image resource.

Note: Starting in Gecko 7.0 {{ geckoRelease("7.0") }}, this value is no longer resolved as a URI; instead, it's treated as a simple string.
bgColor {{ deprecatedGeneric("inline","html4.01") }}, {{ obsoleteGeneric("inline","html5") }} {{ domxref("DOMString") }} Background color for the document.
link {{ deprecatedGeneric("inline","html4.01") }}, {{ obsoleteGeneric("inline","html5") }} {{ domxref("DOMString") }} Color of unvisited links.
onafterprint {{ HTMLVersionInline(5) }} Function Reflects the {{ htmlattrxref("onafterprint", "body") }} HTML attribute value for a function to call after the user has printed the document.
onbeforeprint {{ HTMLVersionInline(5) }} Function Reflects the {{ htmlattrxref("onbeforeprint", "body") }} HTML attribute value for a function to call when the user has requested printing the document.
onbeforeunload {{ HTMLVersionInline(5) }} Function Reflects the {{ htmlattrxref("onbeforeunload", "body") }} HTML attribute value for a function to call when the document is about to be unloaded.
onblur {{ HTMLVersionInline(5) }} Function

Exposes the {{ domxref("window.onblur") }} event handler to call when the window loses focus.

Note: This handler is triggered when the event reaches the window, not the body element. Use {{ domxref("element.addEventListener","addEventListener()") }} to attach an event listener to the body element.
onerror {{ HTMLVersionInline(5) }} Function

Exposes the {{ domxref("window.onerror") }} event handler to call when the document fails to load properly.

Note: This handler is triggered when the event reaches the window, not the body element. Use {{ domxref("element.addEventListener","addEventListener()") }} to attach an event listener to the body element.
onfocus {{ HTMLVersionInline(5) }} Function

Exposes the {{ domxref("window.onfocus") }} event handler to call when the window gains focus.

Note: This handler is triggered when the event reaches the window, not the body element. Use {{ domxref("element.addEventListener","addEventListener()") }} to attach an event listener to the body element.
onhashchange {{ HTMLVersionInline(5) }} Function Reflects the {{ htmlattrxref("onhashchange", "body") }} HTML attribute value for a function to call when the fragment identifier in the address of the document changes.
onload {{ HTMLVersionInline(5) }} Function

Exposes the {{ domxref("window.onload") }} event handler to call when the window gains focus.

Note: This handler is triggered when the event reaches the window, not the body element. Use {{ domxref("element.addEventListener","addEventListener()") }} to attach an event listener to the body element.
onmessage {{ HTMLVersionInline(5) }} Function Reflects the {{ htmlattrxref("onmessage", "body") }} HTML attribute value for a function to call when the document receives a message.
onoffline {{ HTMLVersionInline(5) }} Function Reflects the {{ htmlattrxref("onoffline", "body") }} HTML attribute value for a function to call when network communication fails.
ononline {{ HTMLVersionInline(5) }} Function Reflects the {{ htmlattrxref("ononline", "body") }} HTML attribute value for a function to call when network communication is restored.
onpopstate {{ HTMLVersionInline(5) }} Function Reflects the {{ htmlattrxref("onpopstate", "body") }} HTML attribute value for a function to call when the user has navigated session history.
onredo {{ HTMLVersionInline(5) }} {{ unimplemented_inline() }} Function Reflects the {{ htmlattrxref("onredo", "body") }} HTML attribute value for a function to call when the user has moved forward in undo transaction history.
onresize {{ HTMLVersionInline(5) }} Function Reflects the {{ htmlattrxref("onresize", "body") }} HTML attribute value for a function to call when the document has been resized.
onstorage {{ HTMLVersionInline(5) }} Function Reflects the {{ htmlattrxref("onpopstate", "body") }} HTML attribute value for a function to call when the storage area has changed.
onundo {{ HTMLVersionInline(5) }} {{ unimplemented_inline() }} Function Reflects the {{ htmlattrxref("onundo", "body") }} HTML attribute value for a function to call when the user has moved backward in undo transaction history.
onunload {{ HTMLVersionInline(5) }} Function Reflects the {{ htmlattrxref("onunload", "body") }} HTML attribute value for a function to call when when the document is going away.
text {{ deprecatedGeneric("inline","html4.01") }}, {{ obsoleteGeneric("inline","html5") }} {{ domxref("DOMString") }} Foreground color of text.
vLink {{ deprecatedGeneric("inline","html4.01") }}, {{ obsoleteGeneric("inline","html5") }} {{ domxref("DOMString") }} Color of visited links.

See also

  • {{ HTMLElement("body") }} HTML element

Revision Source

<p>{{ DomRef() }}</p>
<h2 id="HTML_body_element_interface">HTML body element interface</h2>
<p>DOM body elements expose the <a class=" external" href="http://www.w3.org/TR/html5/sections.html#the-body-element" rel="external nofollow" target="_blank" title="http://www.w3.org/TR/html5/sections.html#the-body-element">HTMLBodyElement</a> (or {{ HTMLVersionInline("4") }} <a class=" external" href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-48250443" rel="external nofollow" target="_blank" title="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-48250443"><code>HTMLBodyElement</code></a>) interface, which provides special properties (beyond the regular {{ domxref("element") }} object interface they also have available to them by inheritance) for manipulating body elements.</p>
<h2 id="Properties">Properties</h2>
<table class="standard-table"> <thead> <tr> <th scope="col">Name</th> <th scope="col">Type</th> <th scope="col">Description</th> </tr> </thead> <tbody> <tr> <td><code>aLink</code> {{ deprecatedGeneric("inline","html4.01") }}, {{ obsoleteGeneric("inline","html5") }}</td> <td>{{ domxref("DOMString") }}</td> <td>Color of active hyperlinks.</td> </tr> <tr> <td><code>background</code> {{ deprecatedGeneric("inline","html4.01") }}, {{ obsoleteGeneric("inline","html5") }}</td> <td>{{ domxref("DOMString") }}</td> <td> <p>URI for a background image resource.</p> <div class="note"><strong>Note:</strong> Starting in Gecko 7.0 {{ geckoRelease("7.0") }}, this value is no longer resolved as a URI; instead, it's treated as a simple string.</div> </td> </tr> <tr> <td><code>bgColor</code> {{ deprecatedGeneric("inline","html4.01") }}, {{ obsoleteGeneric("inline","html5") }}</td> <td>{{ domxref("DOMString") }}</td> <td>Background color for the document.</td> </tr> <tr> <td><code>link</code> {{ deprecatedGeneric("inline","html4.01") }}, {{ obsoleteGeneric("inline","html5") }}</td> <td>{{ domxref("DOMString") }}</td> <td>Color of unvisited links.</td> </tr> <tr> <td><code>onafterprint</code> {{ HTMLVersionInline(5) }}</td> <td><code>Function</code></td> <td>Reflects the {{ htmlattrxref("onafterprint", "body") }} HTML attribute value for a function to call after the user has printed the document.</td> </tr> <tr> <td><code>onbeforeprint</code> {{ HTMLVersionInline(5) }}</td> <td><code>Function</code></td> <td>Reflects the {{ htmlattrxref("onbeforeprint", "body") }} HTML attribute value for a function to call when the user has requested printing the document.</td> </tr> <tr> <td><code>onbeforeunload</code> {{ HTMLVersionInline(5) }}</td> <td><code>Function</code></td> <td>Reflects the {{ htmlattrxref("onbeforeunload", "body") }} HTML attribute value for a function to call when the document is about to be unloaded.</td> </tr> <tr> <td><code>onblur</code> {{ HTMLVersionInline(5) }}</td> <td><code>Function</code></td> <td> <p>Exposes the {{ domxref("window.onblur") }} event handler to call when the window loses focus.</p> <div class="note"><strong>Note:</strong> This handler is triggered when the event reaches the window, not the body element. Use {{ domxref("element.addEventListener","addEventListener()") }} to attach an event listener to the body element.</div> </td> </tr> <tr> <td><code>onerror</code> {{ HTMLVersionInline(5) }}</td> <td><code>Function</code></td> <td> <p>Exposes the {{ domxref("window.onerror") }} event handler to call when the document fails to load properly.</p> <div class="note"><strong>Note:</strong> This handler is triggered when the event reaches the window, not the body element. Use {{ domxref("element.addEventListener","addEventListener()") }} to attach an event listener to the body element.</div> </td> </tr> <tr> <td><code>onfocus</code> {{ HTMLVersionInline(5) }}</td> <td><code>Function</code></td> <td> <p>Exposes the {{ domxref("window.onfocus") }} event handler to call when the window gains focus.</p> <div class="note"><strong>Note:</strong> This handler is triggered when the event reaches the window, not the body element. Use {{ domxref("element.addEventListener","addEventListener()") }} to attach an event listener to the body element.</div> </td> </tr> <tr> <td><code>onhashchange</code> {{ HTMLVersionInline(5) }}</td> <td><code>Function</code></td> <td>Reflects the {{ htmlattrxref("onhashchange", "body") }} HTML attribute value for a function to call when the fragment identifier in the address of the document changes.</td> </tr> <tr> <td><code>onload</code> {{ HTMLVersionInline(5) }}</td> <td><code>Function</code></td> <td> <p>Exposes the {{ domxref("window.onload") }} event handler to call when the window gains focus.</p> <div class="note"><strong>Note:</strong> This handler is triggered when the event reaches the window, not the body element. Use {{ domxref("element.addEventListener","addEventListener()") }} to attach an event listener to the body element.</div> </td> </tr> <tr> <td><code>onmessage</code> {{ HTMLVersionInline(5) }}</td> <td><code>Function</code></td> <td>Reflects the {{ htmlattrxref("onmessage", "body") }} HTML attribute value for a function to call when the document receives a message.</td> </tr> <tr> <td><code>onoffline</code> {{ HTMLVersionInline(5) }}</td> <td><code>Function</code></td> <td>Reflects the {{ htmlattrxref("onoffline", "body") }} HTML attribute value for a function to call when network communication fails.</td> </tr> <tr> <td><code>ononline</code> {{ HTMLVersionInline(5) }}</td> <td><code>Function</code></td> <td>Reflects the {{ htmlattrxref("ononline", "body") }} HTML attribute value for a function to call when network communication is restored.</td> </tr> <tr> <td><code>onpopstate</code> {{ HTMLVersionInline(5) }}</td> <td><code>Function</code></td> <td>Reflects the {{ htmlattrxref("onpopstate", "body") }} HTML attribute value for a function to call when the user has navigated session history.</td> </tr> <tr> <td><code>onredo</code> {{ HTMLVersionInline(5) }} {{ unimplemented_inline() }}</td> <td><code>Function</code></td> <td>Reflects the {{ htmlattrxref("onredo", "body") }} HTML attribute value for a function to call when the user has moved forward in undo transaction history.</td> </tr> <tr> <td><code>onresize</code> {{ HTMLVersionInline(5) }}</td> <td><code>Function</code></td> <td>Reflects the {{ htmlattrxref("onresize", "body") }} HTML attribute value for a function to call when the document has been resized.</td> </tr> <tr> <td><code>onstorage</code> {{ HTMLVersionInline(5) }}</td> <td><code>Function</code></td> <td>Reflects the {{ htmlattrxref("onpopstate", "body") }} HTML attribute value for a function to call when the storage area has changed.</td> </tr> <tr> <td><code>onundo</code> {{ HTMLVersionInline(5) }} {{ unimplemented_inline() }}</td> <td><code>Function</code></td> <td>Reflects the {{ htmlattrxref("onundo", "body") }} HTML attribute value for a function to call when the user has moved backward in undo transaction history.</td> </tr> <tr> <td><code>onunload</code> {{ HTMLVersionInline(5) }}</td> <td><code>Function</code></td> <td>Reflects the {{ htmlattrxref("onunload", "body") }} HTML attribute value for a function to call when when the document is going away.</td> </tr> <tr> <td><code>text</code> {{ deprecatedGeneric("inline","html4.01") }}, {{ obsoleteGeneric("inline","html5") }}</td> <td>{{ domxref("DOMString") }}</td> <td>Foreground color of text.</td> </tr> <tr> <td><code>vLink</code> {{ deprecatedGeneric("inline","html4.01") }}, {{ obsoleteGeneric("inline","html5") }}</td> <td>{{ domxref("DOMString") }}</td> <td>Color of visited links.</td> </tr> </tbody>
</table>
<h2 id="See_also">See also</h2>
<ul> <li>{{ HTMLElement("body") }} HTML element</li>
</ul>
Revert to this revision