Meta httpEquivProperty

Meta 对象参考手册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:

linkObject.httpEquiv="HTTP-header"

Return the httpEquiv property:

linkObject.httpEquiv

Some commonHTTP-headervalues:

Value Description
cache-control Controls the caching mechanism of the document.

Allowed values:

  • public - all content will be cached (both the client and proxy servers can cache)
  • private - content is only cached in a private cache (only the client can cache, proxy servers cannot cache)
  • no-cache - do not cache
  • no-store - cache but not archived

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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the httpEquiv attribute.


Example

Example

Display HTTP header information:

<!DOCTYPE html>
<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 对象参考手册Meta Object Other Extensions