Return the relationship between the current document and the linked document:
var x = document.getElementById("myLink").rel;
Click button to return the relationship between the current and the linked document.
<!DOCTYPE html> <html> <head> <link id="myLink" rel="stylesheet" type="text/css" href="style.css"> </head>//from w ww. j av a 2 s .com <body> <h1>I am formatted with a linked style sheet</h1> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myLink").rel; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The rel
property sets or gets a space-separated list that defines the relationship between the current document and the linked document.
Property Values
Value | Description |
---|---|
alternate | an alternative version of the current document |
appendix | appendix page for the current document |
chapter | a chapter |
contents | table of contents for the current document |
copyright | the copyright/policy for the current document |
glossary | the glossary page for the current document |
help | the help page for the current document |
icon | an icon location |
index | the index page for the current document |
next | the next page |
offline | a location that contains a path to the CDF file |
prev | the previous page |
search | an XML file in Open Search description format |
section | a section in a list of documents |
sidebar | the bookmark panel |
start | the first page (used by search engines to show the first page) |
stylesheet | the style sheet for the current document |
subsection | a sub section for the current document |
The rel
property returns a String representing a space-separated list of relationship types.