Meta httpEquivProperty
Meta Object
Definition and Usage
The httpEquiv property sets or returns the HTTP header information in the content attribute.
The http-equiv attribute can be used to simulate HTTP response header information.
The value of the http-equiv attribute depends on the value of the content attribute.
Note:If the name attribute is set, the http-equiv attribute does not need to be set.
Syntax
Set the httpEquiv property:
Return the httpEquiv property:
Some commonHTTP-headervalues:
| Value | Description |
|---|---|
| cache-control | Controls the caching mechanism of the document. Allowed values:
Example: <meta http-equiv="cache-control" content="no-cache"> |
| content-language | The language of the response body. Example: <meta http-equiv="content-language" content="en-US"> |
| content-type | Returns the MIME type of the content. Tip:Usually used for charset settings. Example: <meta http-equiv="content-type" content="text/html; charset=UTF-8"> |
| date | The time the message was sent by the origin server. Example: <meta http-equiv="date" content="Wed, 16 Feb 2011 22:34:13 GMT"> |
| expires | The date and time when the response expires. Example: <meta http-equiv="expires" content="Fri, 30 Dec 2011 12:00:00 GMT"> |
| last-modified | The last modified time of the requested resource. Example: <meta http-equiv="last-modified" content="Mon, 03 Jan 2011 17:45:57 GMT"> |
| location | Used to redirect the recipient to a non-requested URL location to complete the request or identify a new resource. Example: <meta http-equiv="location" content="URL=http://www.example.com"> |
| refresh | Defines how often to refresh the page. Example: <meta http-equiv="refresh" content="300"> |
| set-cookie | Creates a cookie containing the cookie name, cookie value, and expiration time. Example: <meta http-equiv="set-cookie" content="examplecookie=myContent;expires=Fri, 30 Dec 2015 12:00:00 GMT; path=http://www.example.com"> |
| window-target | Specifies the name of the frame to load. |
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the httpEquiv attribute.
Example
Example
Display HTTP header information:
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script>
function displayResult(){
var x=document.getElementsByTagName("meta")[0].httpEquiv;
alert(x);
}
</script>
</head>
<body>
<button type="button" onclick="displayResult()">Display HTTP-Equiv</button>
</body>
</html>
Try it Yourself »
Meta Object Other Extensions