Meta httpEquiv พ ร็อพเพอร์ ตี้
ตัวอย่าง
ส่งคืนส่วนหัว HTTP สำหรับข้อมูลในแอตทริบิวต์เนื้อหา:
var x = document.getElementsByTagName("META")[0].httpEquiv;
ความหมายและการใช้งาน
คุณสมบัติ httpEquiv ตั้งค่าหรือส่งคืนส่วนหัว HTTP สำหรับข้อมูลในแอตทริบิวต์เนื้อหา
สามารถใช้แอตทริบิวต์ http-equiv เพื่อจำลองส่วนหัวการตอบสนอง HTTP
ค่าของแอตทริบิวต์ http-equiv ขึ้นอยู่กับค่าของแอตทริบิวต์เนื้อหา
หมายเหตุ:หากตั้งค่าแอตทริบิวต์ name ไว้ ไม่ควรตั้งค่าแอตทริบิวต์ http-equiv
รองรับเบราว์เซอร์
Property | |||||
---|---|---|---|---|---|
httpEquiv | Yes | Yes | Yes | Yes | Yes |
ไวยากรณ์
ส่งคืนคุณสมบัติ httpEquiv:
metaObject.httpEquiv
ตั้งค่าคุณสมบัติ httpEquiv:
metaObject.httpEquiv = HTTP-header
ค่า ส่วนหัว HTTPที่ใช้กันทั่วไปคือ:
Value | Description |
---|---|
content-type | Specifies the character set for the contents of the document. Tip: It is recommended to always specify the character set. Example: <meta http-equiv="content-type" content="text/html; charset=UTF-8"> |
default-style | Specifies the preferred style sheet to use. Example: <meta http-equiv="default-style" content="the documents preferred stylesheet"> Note: The value of the content attribute above must match the value of the ttitle attribute on a link element in the same document, or it must match the value of the title attribute on a style element in the same document. |
refresh | Defines a time interval for the document to refresh itself.
Example: <meta http-equiv="refresh" content="300"> Note: The value "refresh" should be used carefully, as it takes the control of a page away from the user. Using "refresh" will cause a failure in W3C's Web Content Accessibility Guidelines. |
คืนมูลค่า
Type | Description |
---|---|
String | Information about the HTTP response message header |
ตัวอย่างเพิ่มเติม
ตัวอย่าง
เปลี่ยนค่าของแอตทริบิวต์ http-equiv และเนื้อหา ตัวอย่างต่อไปนี้จะรีเฟรชเอกสารทุกๆ 30 วินาที:
document.getElementsByTagName("META")[0].httpEquiv = "refresh";
document.getElementsByTagName("META")[0].content = "30";
❮ วัตถุ Meta