how do some websites prevent you from using the ‘back’ button to leave the page?

277 views

Often when I’m googling something I’ll go to a few pages, so I’ll click a link, and then use the back button to return to the search results and find another link. But sometimes the back button just reloads the page, and even tapping it multiple times doesn’t work. How and why do some websites do this? Surely it should be my browser that’s controlling if it goes back or not, rather than the website it’s on?

In: 197

11 Answers

Anonymous 0 Comments

If your website is a “single-page web application” style, then pushing the back button would cause your browser to completely leave the application (and possibly losing all data inside). Since this is a common use-case, websites have the ability to override the back button functionality, at least to some extent.

This is in addition to the redirecting shenanigans listed in the other answers.

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