Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I stop people using the back browser button after they have left my site so they cannot return?

I actually need this as a safety feature - the subject of my site is sensitive (domestic violence) - we have a safety area on the site and if clicked the person is taken out of the site to a 'safe' site.

Once they have clicked this area I would like to stop them from coming back for a nominated period of time - (say 1 hour) - so if an abuser came into the room you could escape the site, and even if they hit the back button it would not be obvious what site they were looking at.

Ideas??

like image 571
lyndsey Avatar asked May 11 '11 12:05

lyndsey


People also ask

Can I disable browser back button?

You can-not actually disable the browser back button. However, you can do magic using your logic to prevent the user from navigating back which will create an impression like it is disabled.

How do I prevent someone from going back to previous page?

function preventBack() { window. history. forward(); } setTimeout("preventBack()", 0); window.

How do I disable the Back button in Chrome?

Select Settings from the list. Scroll down to the Privacy and Security section, and select the Site settings from the menu. Choose the Pop-ups and redirects option within Site settings. Toggle the button to turn OFF and block the pop-ups and redirection.


1 Answers

You could always capture the back button event and send the user to a random "safe" url using something like;

window.onbeforeunload = function () {
   location.replace('http://www.bbc.co.uk');
   return "This session is expired and the history altered.";
}

Within the function block you could also simply set a cookie called 'noreturn' which whenever any pages on your site check for could then redirect each time to the "safe" site for the next hour.

There's a decent article on all aspects of controlling the back button and the user's browser history here;

like image 163
Brian Scott Avatar answered Sep 21 '22 17:09

Brian Scott