The referrer
property returns the URL of the document
that loaded the current document.
referrer |
Yes | Yes | Yes | Yes | Yes |
document.referrer
A String type value containing the URL that loaded the current document.
The following code shows how to get the referrer of the current document.
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<button onclick="myFunction()">test</button>
<script>
function myFunction(){<!--from www.j a v a2s.c om-->
var x = document.getElementById("demo");
x.innerHTML=document.referrer;
}
</script>
</body>
</html>
The code above is rendered as follows: