Javascript DOM HTML Document referrer Property

Introduction

Return the referrer of the current document:

View in separate window


<!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.




PreviousNext

Related