HTMLBodyElement
HTMLBodyElement
接口提供了特殊的属性(除了它们继承的常规的HTMLElement
接口)以外,还可以处理 body 元素。属性
从其父项HTMLElement
和WindowEventHandlers
中继承属性。
HTMLBodyElement.aLink
- Is a
DOMString
that represents the color of active hyperlinks. HTMLBodyElement.background
- Is a
DOMString
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
- Is a
DOMString
that represents the background color for the document. HTMLBodyElement.link
- Is a
DOMString
that represents the color of unvisited links. HTMLBodyElement.text
- Is a
DOMString
that represents the foreground color of text. HTMLBodyElement.vLink
- Is a
DOMString
that represents the color of visited links.
方法
No specific methods; inherits methods from its parent, HTMLElement
and from WindowEventHandlers
.
事件处理
No specific event handlers; inherits event handlers from its parent, HTMLElement
and from WindowEventHandlers
.
WindowEventHandlers.onafterprint
- Is an
EventHandler
(en-US) representing the code to be called when theafterprint (en-US)
event is raised. WindowEventHandlers.onbeforeprint
- Is an
EventHandler
(en-US) representing the code to be called when thebeforeprint (en-US)
event is raised. WindowEventHandlers.onbeforeunload
- Is an
EventHandler
(en-US) representing the code to be called when thebeforeunload (en-US)
event is raised. WindowEventHandlers.onhashchange
- Is an
EventHandler
(en-US) representing the code to be called when thehashchange (en-US)
event is raised. WindowEventHandlers.onlanguagechange
- Is an
EventHandler
(en-US) representing the code to be called when thelanguagechange (en-US)
event is raised. WindowEventHandlers.onmessage
- Is an
EventHandler
(en-US) called whenever an object receives amessage
event. WindowEventHandlers.onmessageerror
- Is an
eventHandler
(en-US) called whenever an object receives amessageerror
event. WindowEventHandlers.onoffline
- Is an
EventHandler
(en-US) representing the code to be called when theoffline (en-US)
event is raised. WindowEventHandlers.ononline
- Is an
EventHandler
(en-US) representing the code to be called when theonline (en-US)
event is raised. WindowEventHandlers.onpagehide
- Is an
EventHandler
(en-US) representing the code to be called when thepagehide (en-US)
event is raised. WindowEventHandlers.onpageshow
- Is an
EventHandler
(en-US) representing the code to be called when thepageshow (en-US)
event is raised. WindowEventHandlers.onpopstate
- Is an
EventHandler
(en-US) representing the code to be called when thepopstate (en-US)
event is raised. WindowEventHandlers.onrejectionhandled
(en-US)- An
EventHandler
(en-US) representing the code executed when therejectionhandled
event is raised, indicating that aPromise
was rejected and the rejection has been handled. WindowEventHandlers.onresize
- Is an
EventHandler
(en-US) representing the code to be called when theresize (en-US)
event is raised. WindowEventHandlers.onstorage
- Is an
EventHandler
(en-US) representing the code to be called when thestorage (en-US)
event is raised. WindowEventHandlers.onunhandledrejection
(en-US)- An
EventHandler
(en-US) representing the code executed when theunhandledrejection
event is raised, indicating that aPromise
was rejected but the rejection was not handled. WindowEventHandlers.onunload
- Is an
EventHandler
(en-US) representing the code to be called when theunload (en-US)
event is raised.
规范
Specification | Status | Comment |
---|---|---|
HTML Living Standard HTMLBodyElement |
Living Standard | 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 WindowEventHandlers . HTMLBodyElement implements this interface. |
HTML 5.1 HTMLBodyElement |
Recommendation | |
HTML5 HTMLBodyElement |
Recommendation | 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 . |
Document Object Model (DOM) Level 2 HTML Specification HTMLBodyElement |
Obsolete | No change from Document Object Model (DOM) Level 1 Specification. |
Document Object Model (DOM) Level 1 Specification HTMLBodyElement |
Obsolete | Initial definition. |
浏览器兼容性
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help! (en-US)
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | 1 | (Yes) | 1.0 (1.7 or earlier) [1] | 4.0 | (Yes) [1] | (Yes) |
onXYZ event handlers |
(Yes) | ? | (Yes) | ? | (Yes) | ? |
onlanguage |
未实现 | ? | 32 (32) | ? | 未实现 | ? |
onmessageerror |
60 | ? | ? | ? | 47 | ? |
onstorage |
(Yes) | ? | 45 (45) | ? | (Yes) | ? |
onrejectionhandled and onunhandledrejection |
49 | ? | 未实现 | 未实现 | 36 | 未实现 |
Feature | Android Webview | Chrome for Android | Edge | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | 1.0 (1.0) | (Yes) | (Yes) | (Yes) |
onXYZ event handlers |
(Yes) | (Yes) | ? | (Yes) | ? | (Yes) | ? |
onlangugage |
未实现 | 未实现 | ? | 32.0 (32) | ? | 未实现 | ? |
onmessageerror |
60 | 60 | ? | ? | ? | 47 | ? |
onstorage |
(Yes) | (Yes) | ? | 45.0 (45) | ? | (Yes) | ? |
onrejectionhandled and onunhandledrejection |
49 | 49 | ? | 未实现 | 未实现 | 36 | 未实现 |
[1] Firefox prior to Firefox 7.0 (and some older versions of Opera) returned a URI for the HTMLBodyElement.background
attribute.
参考阅读
- HTML element implementing this interface:
<body>
WindowEventHandlers