Javascript examples for DOM HTML Element:Anchor
The rel property sets or gets the value of the rel attribute of a link.
The rel attribute sets the relationship between the current document and the linked document.
Set the rel property with the following Property Values
Value | Meaning |
---|---|
alternate | An alternate version of the document (such as print page, translated) |
author | The author of the document |
bookmark | A related document |
help | A help document |
licence | Copyright information for the document |
next | The next document in the same selection |
nofollow | "nofollow" is used by Google to specify that the Google search spider should not follow that link |
noreferrer | browser should not send a HTTP referer header if the user follows the hyperlink |
prefetch | the target document should be cached |
prev | The previous document in the same selection |
search | A search tool for the document |
tag | A keyword for the current document |
A String, representing the relationship between the current document and the linked document
The following code shows how to Return the value of the rel attribute of a link:
<!DOCTYPE html> <html> <body> <p><a ref='search' id="myAnchor" href="https://www.java2s.com">java2s.com</a></p> <button onclick="myFunction()">get the value of the rel attribute of the link</button> <p id="demo"></p> <script> function myFunction() {//w w w . j a va 2 s.c o m var v = document.getElementById("myAnchor").rel; document.getElementById("demo").innerHTML = v; } </script> </body> </html>