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

287 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

There’s a command in HTML called `refresh` which allows a webdev to write a page in such a way as your browser reloads the page every 30 seconds, or every minute, or whatever amount of time they choose.

Here’s an example snippet of code which would just refresh the page every 30 seconds:

<meta http-equiv=”refresh” content=”30″>

The refresh command can *also* be used to re*direct* your browser to another address.

Here’s an example snippet of refresh code, which would redirect your browser to w3docs.com after 3 seconds.

<meta http-equiv=”Refresh” content=”3; url=’https://www.w3docs.com'” />

Naughty webdevs will basically use the refresh feature to redirect a page ***to itself***. Unlike the basic refresh, this causes the page to occupy the last two spots in your browsing history rather than only the current one. So when you hit the “back” button, it just goes back to the same page.

It’s a little more complicated than that, but that’s the gist of it.

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