Đối tượng nội dung HTML DOM
Đối tượng cơ thể
Đối tượng Body đại diện cho một phần tử HTML <body>.
Truy cập một đối tượng cơ thể
Bạn có thể truy cập phần tử <body> bằng cách sử dụng getElementsByTagName ():
Thí dụ
var x = document.getElementsByTagName("BODY")[0];
Mẹo: Bạn cũng có thể truy cập phần tử <body> bằng cách sử dụng thuộc tính document.body .
Tạo một đối tượng cơ thể
Bạn có thể tạo một phần tử <body> bằng cách sử dụng phương thức document.createElement ():
var x = document.createElement("BODY");
Thuộc tính đối tượng cơ thể
Property | Description |
---|---|
aLink | Not supported in HTML5. See CSS :active Selector instead.
Sets or returns the color of an active link in a document |
background | Not supported in HTML5. Use style.backgroundImage instead. Sets or returns the background image for a document |
bgColor | Not supported in HTML5. Use style.backgroundColor instead. Sets or returns the background color of a document |
link | Not supported in HTML5. See CSS :link Selector instead. Sets or returns the color of unvisited links in a document |
text | Not supported in HTML5. Use style.color instead. Sets or returns the color of the text in a document |
vLink | Not supported in HTML5. See CSS :visited Selector instead.
Sets or returns the color of visited links in a document |
Thuộc tính và sự kiện tiêu chuẩn
Đối tượng Body cũng hỗ trợ các thuộc tính và sự kiện tiêu chuẩn .
Các trang liên quan
Tham chiếu HTML: thẻ HTML <body>