mozilla

Revision 75999 of HTMLBodyElement

  • Revision slug: DOM/HTMLBodyElement
  • Revision title: HTMLBodyElement
  • Revision id: 75999
  • Created:
  • Creator: jswisher
  • Is current revision? No
  • Comment 463 words added

Revision Content

{{ DomRef() }}

HTML Body Element Interface

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

Properties

Name Type Description
aLink {{ deprecated_inline() }} in {{ HTMLVersionInline("4") }}, {{ obsolete_inline() }} in {{ HTMLVersionInline("5") }} DOMString Color of active hyperlinks.
background {{ deprecated_inline() }} in {{ HTMLVersionInline("4") }}, {{ obsolete_inline() }} in {{ HTMLVersionInline("5") }} DOMString URI for a background image resource.
bgColor {{ deprecated_inline() }} in {{ HTMLVersionInline("4") }}, {{ obsolete_inline() }} in {{ HTMLVersionInline("5") }} DOMString Background color for the document.
link {{ deprecated_inline() }} in {{ HTMLVersionInline("4") }}, {{ obsolete_inline() }} in {{ HTMLVersionInline("5") }} 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 window.onblur event handler to call when the window loses focus.

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

Exposes the window.onerror event handler to call when the document fails to load properly.

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

Exposes the window.onfocus event handler to call when the window gains focus.

Note that this handler is triggered when the event reaches the window, not the body element. Use 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 window.onload event handler to call when the window gains focus.

Note that this handler is triggered when the event reaches the window, not the body element. Use 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.
text {{ deprecated_inline() }} in {{ HTMLVersionInline("4") }}, {{ obsolete_inline() }} in {{ HTMLVersionInline("5") }} DOMString Foreground color of text.
vLink {{ deprecated_inline() }} in {{ HTMLVersionInline("4") }}, {{ obsolete_inline() }} in {{ HTMLVersionInline("5") }} DOMString Color of visited links.

Revision Source

<p>{{ DomRef() }}</p>
<h2>HTML Body Element Interface</h2>
<p>DOM body elements expose the <a class=" external" href="http://www.w3.org/TR/html5/text-level-semantics.html#htmlanchorelement" rel="external nofollow" target="_blank" title="http://www.w3.org/TR/html5/text-level-semantics.html#htmlanchorelement">HTMLBodyElement</a> (or <span style="border: 1px solid rgb(129, 129, 250); background-color: rgb(174, 218, 229); font-size: x-small; white-space: nowrap; padding: 2px;"><a href="../../../../en/HTML" rel="custom nofollow">HTML 4</a></span> <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 <a href="../../../../en/DOM/element" rel="internal">element</a> object interface they also have available to them by inheritance) for manipulating body elements.</p>
<h2>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> {{ deprecated_inline() }} in {{ HTMLVersionInline("4") }}, {{ obsolete_inline() }} in {{ HTMLVersionInline("5") }}</td> <td><a href="/En/DOM/DOMString" title="En/DOM/DOMString"><code>DOMString</code></a></td> <td>Color of active hyperlinks.</td> </tr> <tr> <td><code>background</code> {{ deprecated_inline() }} in {{ HTMLVersionInline("4") }}, {{ obsolete_inline() }} in {{ HTMLVersionInline("5") }}</td> <td><a href="/En/DOM/DOMString" title="En/DOM/DOMString"><code>DOMString</code></a></td> <td>URI for a background image resource.</td> </tr> <tr> <td><code>bgColor</code> {{ deprecated_inline() }} in {{ HTMLVersionInline("4") }}, {{ obsolete_inline() }} in {{ HTMLVersionInline("5") }}</td> <td><a href="/En/DOM/DOMString" title="En/DOM/DOMString"><code>DOMString</code></a></td> <td>Background color for the document.</td> </tr> <tr> <td><code>link</code> {{ deprecated_inline() }} in {{ HTMLVersionInline("4") }}, {{ obsolete_inline() }} in {{ HTMLVersionInline("5") }}</td> <td><a href="/En/DOM/DOMString" title="En/DOM/DOMString"><code>DOMString</code></a></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 <a href="/en/DOM/window.onblur" title="en/DOM/window.onblur">window.onblur</a> event handler to call when the window loses focus. </p> <div class="note">Note that this handler is triggered when the event reaches the window, not the body element. Use <a href="/en/DOM/element.addEventListener" title="en/DOM/element.addEventListener">addEventListener()</a> 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 <a href="/en/DOM/window.onerror" title="en/DOM/window.onerror">window.onerror</a> event handler to call when the document fails to load properly. </p> <div class="note">Note that this handler is triggered when the event reaches the window, not the body element. Use <a href="/en/DOM/element.addEventListener" title="en/DOM/element.addEventListener">addEventListener()</a> 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 <a href="/en/DOM/window.onblur" title="en/DOM/window.onblur">window.onfocus</a> event handler to call when the window gains focus. </p> <div class="note">Note that this handler is triggered when the event reaches the window, not the body element. Use <a href="/en/DOM/element.addEventListener" title="en/DOM/element.addEventListener">addEventListener()</a> 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 <a href="/en/DOM/window.onload" title="en/DOM/window.onload">window.onload</a> event handler to call when the window gains focus. </p> <div class="note">Note that this handler is triggered when the event reaches the window, not the body element. Use <a href="/en/DOM/element.addEventListener" title="en/DOM/element.addEventListener">addEventListener()</a> 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>text</code> {{ deprecated_inline() }} in {{ HTMLVersionInline("4") }}, {{ obsolete_inline() }} in {{ HTMLVersionInline("5") }}</td> <td><a href="/En/DOM/DOMString" title="En/DOM/DOMString"><code>DOMString</code></a></td> <td>Foreground color of text.</td> </tr> <tr> <td><code>vLink</code> {{ deprecated_inline() }} in {{ HTMLVersionInline("4") }}, {{ obsolete_inline() }} in {{ HTMLVersionInline("5") }}</td> <td><a href="/En/DOM/DOMString" title="En/DOM/DOMString"><code>DOMString</code></a></td> <td>Color of visited links.</td> </tr> </tbody>
</table>
Revert to this revision