Meta httpEquiv- eigenschap
Voorbeeld
Retourneer de HTTP-header voor de informatie in het content-attribuut:
var x = document.getElementsByTagName("META")[0].httpEquiv;
Definitie en gebruik
De eigenschap httpEquiv stelt een HTTP-header in of retourneert deze voor de informatie in het content-kenmerk.
Het http-equiv-attribuut kan worden gebruikt om een HTTP-responsheader te simuleren.
De waarde van het http-equiv attribuut hangt af van de waarde van het content attribuut.
Opmerking: als het attribuut name is ingesteld, mag het attribuut http-equiv niet worden ingesteld.
Browserondersteuning
Property | |||||
---|---|---|---|---|---|
httpEquiv | Yes | Yes | Yes | Yes | Yes |
Syntaxis
Retourneer de eigenschap httpEquiv:
metaObject.httpEquiv
Stel de eigenschap httpEquiv in:
metaObject.httpEquiv = HTTP-header
Enkele veelgebruikte HTTP-headerwaarden zijn:
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. |
Winstwaarde
Type | Description |
---|---|
String | Information about the HTTP response message header |
Meer voorbeelden
Voorbeeld
Wijzig de waarde van de kenmerken http-equiv en content. In het volgende voorbeeld wordt het document elke 30 seconden vernieuwd:
document.getElementsByTagName("META")[0].httpEquiv = "refresh";
document.getElementsByTagName("META")[0].content = "30";
❮Meta-object