How to use history.back ()

can i do the following?

window.open ("any URL", "itself")
history.back ()

I want to go to another page and then go back to the previous one, but this aproach doesn't work This is not possible and history.back () cannot be used this way because the scripts on the new page are loaded instead of the old one? Also, I tried to do window.open on one page and make history back from another, it still doesn't work ...

+3


source to share


2 answers


The problem was that the browser did the navigation faster than it saved the previous page in history when I wrapped window.open () (first page) and history.goBack () (other page) with functions and called them with an onclick button. it worked. '
Thanks everyone.



0


source


You may like to use history.go (-1) This will be more efficient and versatile, and give you the added benefit of going further from the previous page. thank



+1


source







All Articles