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

193 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

There’s a mechanism that lets the developers change the URL without having to reload the whole page.

Just look at Reddit when you open a post. It opens it in a sort of popup that you can close. The URL changes but the page doesn’t reload.

You can also click the browser’s back button to go back to the previous page. This is because the browser knows which pages you visited in a given tab, we call this history.

This mechanism can be abused by changing the url many times very quickly, flooding the browser’s history. So when you press back, you’re just iterating over the same page with a slightly different URL.

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