HTML DOM referrer Property Last Updated : 02 Sep, 2024 Comments Improve Suggest changes Like Article Like Report The DOM referrer property in HTML is used to return the URI of the page that linked to the current page. If the user navigates to the page directly or through a bookmark, then this value is an empty string. Syntax:document.referrer The below program illustrates the referrer property in HTML: Example: There are 3 pages that link each other and specify their referrer property below. page1.html <!DOCTYPE html> <html> <head> <title>Referrer Property</title> </head> <body> <h1 style="color: green;">GeeksForGeeks</h1> <h2>Page 1</h2> <p>Click on the below links to go to the other pages</p> <a href="page2.html">Go to Page 2</a> <a href="page3.html">Go to Page 3</a> <p> <b>You are referred to this page by:</b> </p> <div class="referrer"></div> <script> // access the referrer property let referrer = document.referrer; // replace div with the referrer link document.querySelector('.referrer').innerHTML = referrer; </script> </body> </html> page2.html <!DOCTYPE html> <html> <head> <title>Referrer Property</title> </head> <body> <h1 style="color: green;">GeeksForGeeks</h1> <h2>Page 2</h2> <p>Click on the below links to go to the other pages</p> <a href="page1.html">Go to Page 1</a> <a href="page3.html">Go to Page 3</a> <p> <b>You are referred to this page by:</b> </p> <div class="referrer"></div> <script> // access the referrer property let referrer = document.referrer; // replace div with the referrer link document.querySelector('.referrer').innerHTML = referrer; </script> </body> </html> page3.html <!DOCTYPE html> <html> <head> <title>Referrer Property</title> </head> <body> <h1 style="color: green;">GeeksForGeeks</h1> <h2>Page 3</h2> <p>Click on the below links to go to the other pages</p> <a href="page1.html">Go to Page 1</a> <a href="page2.html">Go to Page 2</a> <p> <b>You are referred to this page by:</b> </p> <div class="referrer"></div> <script> // access the referrer property let referrer = document.referrer; // replace div with the referrer link document.querySelector('.referrer').innerHTML = referrer; </script> </body> </html> Supported Browsers: The browser supported by DOM referrer property are listed below: Google ChromeEdge FirefoxOperaSafari Comment More infoAdvertise with us sayantanm19 Follow Improve Article Tags : Web Technologies HTML HTML-DOM Similar Reads HTML ondrop Event Attribute The ondrop event attribute is used to drag an element or text and drop it into a valid droppable location or target. The drag and drop is a common feature of HTML 5. There are different events that are used and occur before ondrop event. Events occur on the draggable targetEvents occur on the drop t 3 min read HTML DOM item() Method The item() method is used to return the node at the specified index. The nodes are sorted as they appear in the source code. The index of the node list starts with 0. Syntax:nodelist.item( index )ornodelist[ index ] Parameters: This method accepts single parameter index which is used to hold the ind 2 min read HTML DOM Style borderRight Property The DOM style borderRight property is used to set or return the three different border-right properties such as border-right-width, border-right-style, and border-right-color of an element. Syntax: It returns the borderRight Property.object.style.borderRightIt is used to set the borderRight property 2 min read HTML DOM Style borderTop Property The DOM style borderTop property is used to set or return the three different border-top property such as border-top-width, border-top-style, and border-top-color of an element. Syntax: It returns the borderTop property. object.style.borderTopIt is used to set the borderTop property. object.style.bo 2 min read HTML DOM documentElement Property The DOM documentElement property is used to return the documentElement as an Element Object. It is a read-only property. It returns a <HTML> Element. Syntax:document.documentElement Return Value: It returns the documentElement of the document or an element object. Example: Below program illust 2 min read HTML DOM Style borderLeft Property HTML DOM Style borderLeft property allows manipulation of the left border style of an element via JavaScript. It controls the border's width, style, and color, affecting the element's visual presentation and layout. HTML DOM Style borderLeft Property Syntax:Get the borderLeft Property.object.style.b 2 min read HTML DOM setNamedItem() Method The setNamedItem() method is used to add a particular node to an attribute node using its name. These attribute nodes are collectively called as namedNodeMap. It can be accessed through a name. If a node is already present in the document, it will replace it and return the updated value. The setName 2 min read HTML DOM scripts Collection The DOM scripts Collection in HTML is used to return the collection of all <script> elements in an HTML document. The script elements are sorted as appear in the sourcecode. Syntax: document.scripts Property Value: It returns the single value length which is the collection of all script eleme 2 min read HTML DOM getElementsByName() Method The getElementsByName() method returns collection of all elements of particular document by name. This collection is called node list and each element of the node list can be visited with the help of the index. Syntax: document.getElementsByName(name) Parameter:This function accepts name of document 2 min read HTML DOM getElementById() Method The getElementById() method returns the elements that have given an ID which is passed to the function. This function is a widely used HTML DOM method in web designing to change the value of any particular element or get a particular element. If the passed ID to the function does not exist then it r 3 min read Like