Gli ultimi tutorial di sviluppo web
 

Meta httpEquiv Proprietà

Meta Object Reference oggetto Meta

Esempio

Ritorna l'intestazione HTTP per le informazioni contenute nel content attributi:

var x = document.getElementsByTagName("META")[0].httpEquiv;

Il risultato di x sarà:

content-type
Prova tu stesso "

Definizione e utilizzo

Gli insiemi di proprietà httpEquiv o restituisce un header HTTP per le informazioni contenute nel content attributo.

Il http-equiv attributo può essere utilizzato per simulare un header di risposta HTTP.

Il valore del http-equiv attributo dipende dal valore del content attributo.

Nota: se il name attributo è impostato, il http-equiv attributo non deve essere impostato.


Supporto per il browser

Internet ExplorerFirefoxOperaGoogle ChromeSafari

La proprietà httpEquiv è supportata in tutti i principali browser.


Sintassi

Restituisce la proprietà httpEquiv:

metaObject .httpEquiv

Impostare la proprietà httpEquiv:

metaObject .httpEquiv=HTTP-header

Alcuni valoriHTTP-intestazionecomunemente usati sono:

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 .

Valore di ritorno

Type Description
String Information about the HTTP response message header

Altri esempi

Esempio

Modificare il valore degli attributi http-equiv e contenuti. Il seguente esempio aggiornare il documento ogni 30 secondi:

document.getElementsByTagName("META")[0].httpEquiv = "refresh";
document.getElementsByTagName("META")[0].content = "30";
Prova tu stesso "

Meta Object Reference oggetto Meta