Gohyu Gohyu - 5 months ago 10
HTML Question

Button return to page where I come - with referrer

I want to create a function where returne to page where I come (previously)

This is my code

<div class="row text-center">
<div class="col-md-12">
<input type="submit" value="Назад" onclick="myFunction()" class="btn" />
</div>
</div>


function myFunction() {
var x = document.referrer;
document.getElementById(".btn").innerHTML = x;
}


Where I'm Wrong ?

hsz hsz
Answer

Try with:

function myFunction() {
  window.location = document.referrer;
}

You can also use:

function myFunction() {
  window.history.back();
}