
定义和用法
name 属性可设置或者返回content属性信息名称。
name 属性值依赖 content 属性值。
Name属性可以预定义值,或由用户定义。/p>
语法
设置 name 属性:
linkObject.name="name"
返回 name 属性:
linkObject.name
预定义 name 值:
值 | 描述 |
---|---|
abstract | 定义了一个二级描述 |
author | 定义文档的作者。 实例: <meta name="author" content="Hege Refsnes"> |
classification | 归类站点到正确类别 |
copyright | 定义文档的版权信息。 实例: <meta name="copyright" content="2011© ziqiangxuetang.com"> |
description | 索引擎可以使用这个描述作为搜索结果。 实例: <meta name="description" content="Free web tutorials"> |
distribution | 规定文件是否可用于Web或Intranet。
实例: |
doc-class | Specifies completion status of the document |
doc-rights | Specifies copyright status of the document |
doc-type | Specifies the type of the document |
DownloadOptions | The associated content property determines what buttons are visible on the File Download dialog box |
expires | Specifies the date and time when the page expires. 实例: <meta name="expires" content="Fri, 10 Jun 2011 12:00:00 GMT"> |
generator | Specifies the name of the program that generated the document |
googlebot | Informs the Google search engine about indexing, archiving and link-following rules.
实例: |
keywords | Informs search engines what your site is about. Tip: Always specify keywords (needed by search engines to catalogize the page). 实例: <meta http-equiv="keywords" content="HTML, HTML DOM, JavaScript"> |
MSSmartTagsPreventParsing | Prevents any Microsoft product from automatically generating smart tags |
name | Specifies the name of the document |
owner | Defines the owner of the page or site |
progid | Defines the id of a program used to generate the document |
rating | Defines webpage rating |
refresh | The document will display for a specified amount of time before refreshing or switch to a new URL. 实例: <meta name="refresh" content="10"> <meta name="refresh" content="10;URL=https://code.tuweizhong.com"> |
reply-to | Defines an email address of a contact for the document |
resource-type | Defines the type of web resource |
revisit-after | Defines how often search engine spiders should revisit the site |
robots | Defines page indexing mechanisms for robots, search engine indexing and link-following rules. The content attribute should contain a comma separated list of the following values:
实例: |
Template | The content attribute should specify the location of the template used to edit the document |
others | You can define your own names in a schema |
浏览器支持
所有主要浏览器都支持 name 属性
实例
实例
显示 <meta> 标签 name 属性的值:
<html>
<head>
<meta name="keywords" content="HTML,HTML DOM,JavaScript">
<script>
function displayResult()
{
var x=document.getElementsByTagName("meta")[0].name;
alert(x);
}
</script>
</head>
<body>
<button type="button" onclick="displayResult()">Display meta name</button>
</body>
</html>
<head>
<meta name="keywords" content="HTML,HTML DOM,JavaScript">
<script>
function displayResult()
{
var x=document.getElementsByTagName("meta")[0].name;
alert(x);
}
</script>
</head>
<body>
<button type="button" onclick="displayResult()">Display meta name</button>
</body>
</html>
尝试一下 »
