C
C
Coder3212016-09-15 11:18:16
JavaScript
Coder321, 2016-09-15 11:18:16

How, when clicking on the back button of the browser, send the user to the previous site?

Such a situation, after authorization, I want to block the user from entering the login page. I coped with this, but when the user presses the back button from the next page after the login, nothing happens, since he cannot enter this page. Can I somehow determine that it was the browser's back button that was pressed and at the same time send it to the page that was before login?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alex, 2016-09-15
@Kozack

Read about history.replaceState(). With it, you can replace the current authorization page in the browser history. Thus, when you click the "Back" button, the user will be sent to the page on which he was BEFORE the authorization page.

B
burtulug, 2016-09-15
@burtulug

As an option: immediately after login, make history.replaceState on the page where the user should be directed, then there will be no authorization page in the history. https://developer.mozilla.org/ru/docs/Web/API/Hist...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question