How do some websites prevent us from going back to the previous page?

197 views

Do you know these shady websites that don’t allow you to go back, only after spamming the previous page button, or in some cases, the only option is to close the tab. How can web devs disable basic browser functions like that?

In: 4

4 Answers

Anonymous 0 Comments

Ah the thing is for certain types of websites that update dynamically with like JavaScript, instead of clicking a link and reloading the entire page, it’s important to be able to tell the browser directly that pressing the back button goes to a specific state. That way after clicking a few menus, pressing back takes you to before you clicked a menu item and not away from the website.

Spam websites just highjack that same mechanism to flood the back button entries. So you click back and it reloads the current spam, and floods some more fake entries into the history.

You are viewing 1 out of 4 answers, click here to view all answers.