Anchor rel 屬性
實例
例子 1
返回鏈接的 rel 屬性值:
var x = document.getElementById("myAnchor").rel;
例子 2
將 rel 屬性的值設置為 "nofollow":
document.getElementById("myAnchor").rel = "nofollow";
語法
返回 rel 屬性:
anchorObject.rel
設置 rel 屬性:
anchorObject.rel = "value"
屬性值
值 | 描述 |
---|---|
alternate | 文檔的替代版本(比如打印頁、翻譯或鏡像)。 |
author | 文件的作者。 |
bookmark | 相關文檔。 |
help | 幫助文檔。 |
licence | 文檔的版權信息。 |
next | 集合中的下一份文檔。 |
nofollow | Google 使用 "nofollow" 來規定 Google 搜索蜘蛛不應跟隨該鏈接(主要用于付費鏈接)。 |
noreferrer | 規定如果用戶點擊超鏈接,瀏覽器不應發送 HTTP 引用標頭。 |
prefetch | 規定應緩存目標文檔。 |
prev | 集合中的上一份文檔。 |
search | 文檔的搜索工具。 |
tag | 當前文檔的標簽(關鍵字)。 |
技術細節
返回值: | 字符串值,表示當前文檔和鏈接文檔的關系。 |
---|
瀏覽器支持
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
支持 | 支持 | 支持 | 支持 | 支持 |
相關頁面
HTML 參考手冊:HTML <a> rel 屬性