1

I am not able to get previous page URL using "referrer". Suppose I am going from page A to B. And by clicking browser back button I am returning back to Page A again. Now I want to check my previous page URL is B. How can I check it with Javascript. I have to check this on page load. When returning back to Page A, I did not any value.

<script>          
 window.onload = function(){                           
    alert('hit '+document.referrer);              
 }
</script>

Thanks in advance.

abhishek
  • 51
  • 2
  • 11

2 Answers2

0

If you have inner website's pages on the same root (folder), you can go through these pages in this way: Also you can a tag wrap with button tag.

<a href = "A page.html">A page</a>
<a href = "B page.html">B page</a>
darionas
  • 11
  • 5
-1

Try this:

<script>
function goBack() {
  window.history.back()
}
</script>
 <html>
<head>
<!--Insert script here -->
</head>
<body>

<input type="button" value="Back" onclick="goBack()">

</body>
</html> 

Or read: here

darionas
  • 11
  • 5