Latest web development tutorials

Properti HTML DOM Meta httpEquiv

Referensi Obyek Meta meta Object

Definisi dan Penggunaan

httpEquiv set properti atau mengembalikan konten properti di header HTTP.

Atribut http-equiv dapat digunakan kamuflase header respon HTTP.

http-equiv nilai atribut tergantung pada nilai dari properti konten.

Catatan: Jika atributnama telah ditetapkan, atribut http-equiv tidak perlu untuk mengatur.

tatabahasa

Pengaturan httpEquiv sifat:

linkObject.httpEquiv="HTTP-header"

Kembali sifat httpEquiv:

linkObject.httpEquiv

Beberapa yang umum digunakan nilaiHTTP-header:

描述
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 指定要载入的框架名


Dukungan Browser

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Semua browser utama mendukung properti httpEquiv


contoh

contoh

Menampilkan informasi header 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>

Coba »


Referensi Obyek Meta meta Object