-2

I need to make a script that redirects the user the same way as if the back button on the webbrowser was pushed. How, and is it possible?

  setTimeout(function () {
      window.location.href = "???";
  }, 3000);

5 Answers5

4

Try using the History object:

history.back()
Konerak
  • 39,272
  • 12
  • 98
  • 118
3

Here you go:

setTimeout(function() {
    window.history.go(-1);
}, 3000);
T. Junghans
  • 11,385
  • 7
  • 52
  • 75
1

history.back()

The back() method of the history object loads the previous URL in the History list. The functionality results are the same as pressing the previous button of the browser.

General syntax of back method of history Object:

history.back();

Ben
  • 4,392
  • 3
  • 23
  • 20
1

window.history.back().

You cannot read previous URL, though.

kirilloid
  • 14,011
  • 6
  • 38
  • 52
1

i found this code, it's untested so... you know...

    history.go(-1)
Th0rndike
  • 3,406
  • 3
  • 22
  • 42