HTML DOM教程 37-HTML DOM Meta 對象
1:Meta 對象
Meta 對象代表 HTML 的 一個 <meta> 元素。
<meta> 元素可提供有關某個 HTML 元素的元資訊 (meta-information),比如描述、針對搜尋引擎的關鍵詞以及重新整理頻率。
2:Meta Object Properties
| 屬性 |
描述 |
IE |
F |
O |
W3C |
| content |
設定或返回 <meta> 元素的 content 屬性的值。 |
5 |
1 |
9 |
Yes |
| httpEquiv |
把 content 屬性串連到一個 HTTP 頭部。 |
5 |
1 |
9 |
Yes |
| name |
把 content 屬性串連到某個名稱。 |
5 |
1 |
9 |
Yes |
| scheme |
設定或返回用於解釋 content 屬性的值的格式。 |
6 |
1 |
9 |
Yes |
3:scheme 屬性
本例返回用於解釋 content 屬性的值的格式:
<html>
<head>
<meta name="revised" content="2006-11-03" scheme="YYYY-MM-DD" />
</head>
<body>
<script type="text/javascript">
x=document.getElementsByTagName("meta")[0];
document.write("Content format: " + x.scheme);
</script>
</body>
</html>
4:讓頁面5秒後重新導向
<html>
<head>
<meta http-equiv="refresh" content="5;url=http://www.w3school.com.cn" />
</head>
<body>
<script type="text/javascript">
x=document.getElementsByTagName("meta")[0];
document.write("Http equiv: " + x.httpEquiv);
</script>
<p>We have moved! The new URL is: <a href="http://www.w3school.com.cn">http: //www.w3school.com.cn</a></p>
<p>You will be redirected to the new address in five seconds. If you see this message for more than 5 seconds, please click on the link above.</p>
</body>
</html>
5:讓頁面每5秒鐘重新整理一次
<html>
<head>
<meta http-equiv="refresh" content="5" />
</head>
<body>
<script type="text/javascript">
x=document.getElementsByTagName("meta")[0];
document.write("Http equiv: " + x.httpEquiv);
</script>
</body>
</html>