原文地址:http://dancewithnet.com/2004/12/13/effect-of-meat-in-html/#more-844
meta是用來在HTML文檔中模擬HTTP協(xié)議的響應(yīng)頭報(bào)文。meta 標(biāo)簽用于網(wǎng)頁的<head />與</head />中,
meta 標(biāo)簽的用處很多。meta 的屬性有兩種:name和http-equiv。name屬性主要用于描述網(wǎng)頁,對(duì)應(yīng)于
content(網(wǎng)頁內(nèi)容),以便于搜索引擎機(jī)器人查找、分類(目前幾乎所有的搜索引擎都使用網(wǎng)上機(jī)器人
自動(dòng)查找meta值來給網(wǎng)頁分類)。這其中最重要的是description(站點(diǎn)在搜索引擎上的描述)和
keywords(分類關(guān)鍵詞),所以應(yīng)該給每頁加一個(gè)meta值。比較常用的有以下幾個(gè):
name 屬性
<meta name="generator" content="" />用以說明生成工具(如Microsoft FrontPage 4.0)等;
<meta name="keywords" content="" />向搜索引擎說明你的網(wǎng)頁的關(guān)鍵詞;
<meta name="description" content="" />告訴搜索引擎你的站點(diǎn)的主要內(nèi)容;
<meta name="author" content="你的姓名" />告訴搜索引擎你的站點(diǎn)的制作的作者;
<meta name="robots" content="all|none|index|noindex|follow|nofollow" />
其中的屬性說明如下:
設(shè)定為all:文件將被檢索,且頁面上的鏈接可以被查詢;
設(shè)定為none:文件將不被檢索,且頁面上的鏈接不可以被查詢;
設(shè)定為index:文件將被檢索;
設(shè)定為follow:頁面上的鏈接可以被查詢;
設(shè)定為noindex:文件將不被檢索,但頁面上的鏈接可以被查詢;
設(shè)定為nofollow:文件將不被查詢,但頁面上的鏈接可以被檢索。
http-equiv屬性
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />和 <meta http-
equiv="Content-Language" content="zh-cn" />用以說明主頁制作所使用的文字以及語言;又如英文是
ISO-8859-1字符集,還有g(shù)bk、big5、utf-8、shift-jis、euc、koi8-2等字符集;
<meta http-equiv="refresh" content="n;url=http://yourlink" />定時(shí)讓網(wǎng)頁在指定的時(shí)間n內(nèi),跳
轉(zhuǎn)到頁面http;//yourlink;
<meta http-equiv="expires" content="Mon,12 May 2001 00:20:00 GMT" />可以用于設(shè)定網(wǎng)頁的到期
時(shí)間,一旦過期則必須到服務(wù)器上重新調(diào)用。需要注意的是必須使用GMT時(shí)間格式;
<meta http-equiv="pragma" content="no-cache" />是用于設(shè)定禁止瀏覽器從本地機(jī)的緩存中調(diào)閱頁面
內(nèi)容,設(shè)定后一旦離開網(wǎng)頁就無法從Cache中再調(diào)出;
<meta http-equiv="set-cookie" content="Mon,12 May 2001 00:20:00 GMT" />cookie設(shè)定,如果網(wǎng)頁
過期,存盤的cookie將被刪除。需要注意的也是必須使用GMT時(shí)間格式;
<meta http-equiv="pics-label" content="" />網(wǎng)頁等級(jí)評(píng)定,在IE的internet選項(xiàng)中有一項(xiàng)內(nèi)容設(shè)置
,可以防止瀏覽一些受限制的網(wǎng)站,而網(wǎng)站的限制級(jí)別就是通過meta屬性來設(shè)置的;
<meta http-equiv="windows-target" content="_top" />強(qiáng)制頁面在當(dāng)前窗口中以獨(dú)立頁面顯示,可以
防止自己的網(wǎng)頁被別人當(dāng)作一個(gè)frame頁調(diào)用;
<meta http-equiv="Page-Enter" content="revealTrans(duration=10,transtion=50)" />和<meta
http-equiv="Page-Exit" content="revealTrans(duration=20,transtion=6)" />設(shè)定進(jìn)入和離開頁面
時(shí)的特殊效果,這個(gè)功能即FrontPage中的“格式/網(wǎng)頁過渡”,不過所加的頁面不能夠是一個(gè)frame頁面
。