HTML DOM rel 属性
定义和用法
rel 属性设置或返回当前文档和目标 URL 之间的关系。
rel和rev属性协同工作。搜索引擎使用这两个属性来提供链接的导航菜单。
语法
linkObject.rel=relationship
rel 属性可以具有以下值之一:
值 | 描述 |
---|---|
appendix | Link to the appendix page of the document(链接到文档的附录页面) |
alternate | Link to an alternative source of the document(链接到文档的其他来源) |
bookmark | Link to a bookmark(链接到书签) |
chapter | Link to a chapter(链接到章节) |
contents | Link to the table of contents of the document(链接到文档目录) |
copyright | Link to copyright or the policy of the document(链接到文档的版权或策略) |
glossary | Link to the glossary page of the document(指向文档词汇表页面的链接) |
index | Link to the index page of the document(链接到文档的索引页) |
next | Link to the next page(链接到下一页) |
prev | Link to the previous page(链接到上一页) |
section | Link to a section in a list of documents(链接到文档列表中的某个部分) |
start | Link to the first page (used by search engines to show the first page)(链接到首页(搜索引擎使用它来显示首页)) |
stylesheet | Link to the style sheet of the document(链接到文档的样式表) |
subsection | Link to a sub-section in a list of current documents(链接至当前文档列表中的小节) |
实例
以下示例返回当前文档与目标 URL 之间的关系:
<html> <head> <link rel="stylesheet" type="text/css" id="style1" href="try_dom_link.css" /> </head> <body> <script type="text/javascript"> x=document.getElementById("style1"); document.write("Relationship: " + x.rel); </script> </body> </html>