--- title: HTMLBodyElement slug: Web/API/HTMLBodyElement translation_of: Web/API/HTMLBodyElement ---
HTMLBodyElement
接口提供了特殊的属性(除了它们继承的常规的{{ domxref("HTMLElement") }}接口)以外,还可以处理 body 元素。{{InheritanceDiagram(600, 120)}}
从其父项{{domxref("HTMLElement")}} 和{{domxref("WindowEventHandlers")}}中继承属性。
No specific methods; inherits methods from its parent, {{domxref("HTMLElement")}} and from {{domxref("WindowEventHandlers")}}.
No specific event handlers; inherits event handlers from its parent, {{domxref("HTMLElement")}} and from {{domxref("WindowEventHandlers")}}.
Specification | Status | Comment |
---|---|---|
{{SpecName('HTML WHATWG', "sections.html#the-body-element", "HTMLBodyElement")}} | {{Spec2('HTML WHATWG')}} | Technically, the event-related properties onafterprint , onbeforeprint , onbeforeunload , onblur , onerror , onfocus , onhashchange , onlanguagechange , onload , onmessage , onoffline , ononline , onpopstate , onresize , onstorage , and onunload , have been moved to {{domxref("WindowEventHandlers")}}. HTMLBodyElement implements this interface. |
{{SpecName('HTML5.1', "sections.html#the-body-element", "HTMLBodyElement")}} | {{Spec2('HTML5.1')}} | |
{{SpecName('HTML5 W3C', "sections.html#the-body-element", "HTMLBodyElement")}} | {{Spec2('HTML5 W3C')}} | The following properties are now obsolete: aLink , bgColor , background , link , text , and vLink .The following properties have been added: onafterprint , onbeforeprint , onbeforeunload , onblur , onerror , onfocus , onhashchange , onload , onmessage , onoffline , ononline , onpopstate , onresize , onstorage , and onunload . |
{{SpecName('DOM2 HTML', 'html.html#ID-62018039', 'HTMLBodyElement')}} | {{Spec2('DOM2 HTML')}} | No change from {{SpecName("DOM1")}}. |
{{SpecName('DOM1', 'level-one-html.html#ID-62018039', 'HTMLBodyElement')}} | {{Spec2('DOM1')}} | Initial definition. |
{{CompatibilityTable}}
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | {{CompatChrome(1)}} | {{CompatVersionUnknown}} | {{CompatGeckoDesktop(1.0)}} [1] | 4.0 | {{CompatVersionUnknown}} [1] | {{CompatVersionUnknown}} |
onXYZ event handlers |
{{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} |
onlanguage |
{{CompatNo}} | {{CompatUnknown}} | {{CompatGeckoDesktop(32)}} | {{CompatUnknown}} | {{CompatNo}} | {{CompatUnknown}} |
onmessageerror |
{{CompatChrome(60)}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatOpera(47)}} | {{CompatUnknown}} |
onstorage |
{{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatGeckoDesktop(45)}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} |
onrejectionhandled and onunhandledrejection |
{{CompatChrome(49)}} | {{CompatUnknown}} | {{CompatNo}} | {{CompatNo}} | {{CompatOpera(36)}} | {{CompatNo}} |
Feature | Android Webview | Chrome for Android | Edge | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatGeckoMobile(1.0)}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
onXYZ event handlers |
{{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} |
onlangugage |
{{CompatNo}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatGeckoMobile(32)}} | {{CompatUnknown}} | {{CompatNo}} | {{CompatUnknown}} |
onmessageerror |
{{CompatChrome(60)}} | {{CompatChrome(60)}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatOperaMobile(47)}} | {{CompatUnknown}} |
onstorage |
{{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatGeckoMobile(45)}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} |
onrejectionhandled and onunhandledrejection |
{{CompatChrome(49)}} | {{CompatChrome(49)}} | {{CompatUnknown}} | {{CompatNo}} | {{CompatNo}} | {{CompatOperaMobile(36)}} | {{CompatNo}} |
[1] Firefox prior to Firefox 7.0 (and some older versions of Opera) returned a URI for the HTMLBodyElement.background
attribute.