Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Document.head

翻譯不完整。請協助 翻譯此英文文件

回傳當前文件的 <head> 元素。如果該文件有超過一個 <head> 元素,那只會回傳第一個 <head> 元素。

語法

var objRef = document.head;

範例

// in HTML: <head id="my-document-head">
var aHead = document.head;

alert(aHead.id); // "my-document-head";

alert( document.head === document.querySelector("head") ); // true

Notes

document.head 是「唯讀」。若是想要將 document.head 改成別的值會失敗,這時有些瀏覽器不會告知任何錯誤訊息;有些,例如在 ECMAScript Strict 模式下 的 Gecko 瀏覽器,會給出 TypeError 異常。

規格

Specification Status Comment
WHATWG HTML Living Standard
The definition of 'Document.head' in that specification.
Living Standard Initial definition.
HTML5.1
The definition of 'Document.head' in that specification.
Working Draft  
HTML5
The definition of 'Document.head' in that specification.
Recommendation  

瀏覽器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 4.0 4.0 (2) 9.0 11.0 5.0
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) 4.0 (2) 9.0 (Yes) (Yes)

延伸閱讀

文件標籤與貢獻者

 此頁面的貢獻者: Shiyou
 最近更新: Shiyou,