body HTML元素

来源:百度文库 编辑:神马文学网 时间:2024/04/29 05:53:24
定义
指明文档主体的开始和结束。
Specifies the beginning and end of the document body.
注释
在 Internet Explorer 6 中,如果你使用 !DOCTYPE 声明指定为标准兼容模式,body 对象可以从其内容获取其大小,或者你可以像 div 对象那样严格设置其大小。在标准兼容模式下,html 元素会代表文档可显示内容的整个外观。如果 !DOCTYPE 声明并不指定标准兼容模式,以及较早版本的 Internet Explorer,则是 body 对象代表文档可显示内容的整个外观。body 对象的大小无法更改,它等于窗口的大小。你在此对象上设置的边距位于此对象的边框和滚动条之内。
你可以在脚本中通过 document 对象来访问 body 元素。
元素 body 的 window 对象可以处理 onblur, onfocus, onload, 或 onunload 事件。
此元素在 Internet Explorer 3.0 及以上版本的 HTML 中可用,在 Internet Explorer 4.0 及以上版本的脚本中可用。
此元素是块元素。
此元素需要关闭标签。
As of Internet Explorer 6, when you use the !DOCTYPE declaration to specify standards-compliant mode, the body object can obtain its size from its content, or you can set its size explicitly—like a div object, for example. In standards-compliant mode, the html element represents the entire surface onto which a document‘s contents can be rendered. When the !DOCTYPE declaration does not specify standards-compliant mode, and with earler versions of Internet Explorer, the body object represents the entire surface onto which a document‘s contents can be rendered. The size of the body object cannot be changed and is equal to the size of the window. Margins you set on this object are rendered inside the border and scrollbars of the object.
You can access the body element from script through the document object.
The window object for the body element can host event handlers for the onblur, onfocus, onload, or onunload events.
This element is available in HTML as of Internet Explorer 3.0, and in script as of Internet Explorer 4.0.
This element is a block element.
This element requires a closing tag.
示例代码
演示示例:一个非常简单的HTML文件
下面的例子在脚本中引用了 body 元素。
This example exposes the body element in script.
var oBody = document.body;