Javascript examples for DOM:Document referrer
The referrer property returns the URL of the document that loaded the current document.
A String, representing the URL of the document that loaded the current document.
If the current document was not opened through a link (for example, via a bookmark), an empty string is returned.
The following code shows how to return the referrer of the current document:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">test</button> <p id="demo"></p> <script> function myFunction() {// w w w.jav a 2s.co m var x = document.referrer; document.getElementById("demo").innerHTML = x; } </script> </body> </html>