Latest web development tutorials

HTML DOM 메타 httpEquiv 속성

메타 객체 참조 메타 오브젝트

정의 및 사용

httpEquiv 속성 집합 또는 HTTP 헤더의 속성 내용을 반환합니다.

HTTP-당량 특성 위장 HTTP 응답 헤더를 사용할 수있다.

HTTP-당량 속성 값은 콘텐츠 속성의 값에 따라 달라집니다.

주 : name 속성이 설정되어있는 경우, HTTP-당량 특성을 설정할 필요는 없다.

문법

httpEquiv 속성 설정 :

linkObject.httpEquiv="HTTP-header"

위로 httpEquiv 속성 :

linkObject.httpEquiv

일부 일반적으로 사용되는HTTP 헤더 값:

描述
cache-control 控制文档的缓存机制。

允许的值:

  • public - 所有内容都将被缓存(客户端和代理服务器都可缓存)
  • private - 内容只缓存到私有缓存中(仅客户端可以缓存,代理服务器不可缓存)
  • no-cache - 不缓存
  • no-store - 缓存当不归档 but not archived

实例:

<meta http-equiv="cache-control" content="no-cache">

content-language 响应体的语言

实例:

<meta http-equiv="content-language" content="en-US">

content-type 返回内容的MIME类型

提示:通常用于字符集的设置。

实例:

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

date 原始服务器消息发出的时间

实例:

<meta http-equiv="date" content="Wed, 16 Feb 2011 22:34:13 GMT">

expires 响应过期的日期和时间

实例:

<meta http-equiv="expires" content="Fri, 30 Dec 2011 12:00:00 GMT">

last-modified 请求资源的最后修改时间

实例:

<meta http-equiv="last-modified" content="Mon, 03 Jan 2011 17:45:57 GMT">

location 用来重定向接收方到非请求URL的位置来完成请求或标识新的资源

实例:

<meta http-equiv="location" content="URL=http://www.w3big.com">

refresh 定义间隔多久后刷新页面。

实例:

<meta http-equiv="refresh" content="300">

set-cookie 创建一个 cookie ,包含了 cookie 名,cookie 值,过期时间。

实例:

<meta http-equiv="set-cookie" content="w3bigcookie=myContent;expires=Fri, 30 Dec 2015 12:00:00 GMT; path=http://www.w3big.com">

window-target 指定要载入的框架名


브라우저 지원

Internet ExplorerFirefoxOperaGoogle ChromeSafari

모든 주요 브라우저는 httpEquiv 속성을 지원


HTTP 헤더 정보 표시

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.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()">显示 HTTP-Equiv</button>

</body>
</html>

»시도


메타 객체 참조 메타 오브젝트