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??
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.
function preventBack() { window. history. forward(); } setTimeout("preventBack()", 0); window.
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.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With