Return the referrer of the current document:
<!DOCTYPE html> <html> <head> <title>My title</title> </head>/*from ww w. j av a 2s.c om*/ <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.referrer; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The referrer property returns the URL of the document that loaded the current document.