I´m trying to show (ALERT) the URL of the previous page. So...
<script>
var referrer = document.referrer;
alert(referrer);
</script>
But doesn´t work. The idea is, for example, if user is on the url: www.domain.com/page2.php and return to the previous with the previous button of the browser, show on the previous, for example, www.domain.com/page1.php an alert msg with the content
www.domain.com/page2.php
The CODE show an empty alert when I charge the page (www.domain.com/page1.php) that has it.
But when I go to the page www.domain.com/page2.php (with a button inside a form) and then, I click over the return arrow of the browser, the code did not execute.
Anyone knows why?