The HTMLBodyElement interface provides special properties (beyond those inherited from the regular HTMLElement interface) for manipulating <body> elements.
The HTMLBodyElement interface provides special properties (beyond those inherited from the regular HTMLElement interface) for manipulating <body> elements.
Inherits properties from its parent, HTMLElement.
HTMLBodyElement.aLink Deprecated
A string that represents the color of active hyperlinks.
HTMLBodyElement.background Deprecated
A string that represents the description of the location of the background image resource. Note that this is not an URI, though some older version of some browsers do expect it.
HTMLBodyElement.bgColor Deprecated
A string that represents the background color for the document.
HTMLBodyElement.link Deprecated
A string that represents the color of unvisited links.
HTMLBodyElement.text Deprecated
A string that represents the foreground color of text.
HTMLBodyElement.vLink Deprecated
A string that represents the color of visited links.
No specific methods; inherits methods from its parent, HTMLElement.
The HTMLElement events are inherited.
The following Window onXYZ event handler properties are also available as aliases targeting the window object. However, it is advised to listen to them on the window object directly rather than on HTMLBodyElement.
Note: Using addEventListener() on HTMLBodyElement will not work for the onXYZ event handlers listed below. Listen to the events on the window object instead.
HTMLBodyElement.onafterprintFired after the associated document has started printing or the print preview has been closed.
HTMLBodyElement.onbeforeprintFired when the associated document is about to be printed or previewed for printing.
HTMLBodyElement.onbeforeunloadFired when the window, the document and its resources are about to be unloaded.
HTMLBodyElement.ongamepadconnectedFired when the browser detects that a gamepad has been connected or the first time a button/axis of the gamepad is used.
HTMLBodyElement.ongamepaddisconnectedFired when the browser detects that a gamepad has been disconnected.
HTMLBodyElement.onhashchangeFired when the fragment identifier of the URL has changed (the part of the URL beginning with and following the # symbol).
HTMLBodyElement.onlanguagechangeFired when the user's preferred language changes.
HTMLBodyElement.onmessageFired when the window receives a message, for example from a call to Window.postMessage() from another browsing context.
HTMLBodyElement.onmessageerrorFired when the window receives a message that can't be deserialized.
HTMLBodyElement.onofflineFired when the browser has lost access to the network and the value of Navigator.onLine switches to false.
HTMLBodyElement.ononlineFired when the browser has gained access to the network and the value of Navigator.onLine switches to true.
HTMLBodyElement.onpagehideFired when the browser hides the current page in the process of presenting a different page from the session's history.
HTMLBodyElement.onpageshowFired when the browser displays the window's document due to navigation.
HTMLBodyElement.onpopstateFired when the active history entry changes while the user navigates the session history.
HTMLBodyElement.onrejectionhandledFired whenever a JavaScript Promise is rejected and the rejection has been handled.
HTMLBodyElement.onstorageFired when a storage area (localStorage) has been modified in the context of another document.
HTMLBodyElement.onunhandledrejectionFired whenever a Promise is rejected but the rejection was not handled.
HTMLBodyElement.onunloadFired when the document is being unloaded.
| Specification |
|---|
| HTML Standard # htmlbodyelement |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
HTMLBodyElement |
1 | 12 | 1 | 4 | ≤12.1 | 3 | 4.4 | 18 | 4 | ≤12.1 | 1 | 1.0 |
aLink |
1 | 12 | 1 | 4 | ≤12.1 | 3 | 4.4 | 18 | 4 | ≤12.1 | 1 | 1.0 |
background |
1 | 12 | 1 | 4 | ≤12.1 | 3 | 4.4 | 18 | 4 | ≤12.1 | 1 | 1.0 |
bgColor |
1 | 12 | 1 | 4 | ≤12.1 | 3 | 4.4 | 18 | 4 | ≤12.1 | 1 | 1.0 |
link |
1 | 12 | 1 | 4 | ≤12.1 | 3 | 4.4 | 18 | 4 | ≤12.1 | 1 | 1.0 |
text |
1 | 12 | 1 | 4 | ≤12.1 | 3 | 4.4 | 18 | 4 | ≤12.1 | 1 | 1.0 |
vLink |
1 | 12 | 1 | 4 | ≤12.1 | 3 | 4.4 | 18 | 4 | ≤12.1 | 1 | 1.0 |
<body>
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement