Go back to the previous page by defining a variable

3

I would like to do the following

  echo "<script>window.history.back()</script>";

this returns you to the previous page

What I intended was to go back to the previous page but define a variable

imagine that the previous page is example.php

I wanted you to do "example.php? a = 1"

    
asked by anonymous 19.07.2016 / 12:22

1 answer

3

To get the previous url:

document.referrer

To redirect to the previous url with additional parameters:

window.location.href = document.referrer+ '?a=1';
    
19.07.2016 / 12:29