6

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??

skaffman
  • 398,947
  • 96
  • 818
  • 769
lyndsey
  • 61
  • 2
  • 3
    Note however that the site will remain in history list etc., so suggest to your users to use the browser's Private Mode or a similar feature. – Piskvor left the building May 11 '11 at 12:33
  • @Piskvor: That's why I suggested using location.replace. It will at least replace the history of the current page with the "safe" page which is better than nothing. Your point is completely valid and worth noting. – Brian Scott May 11 '11 at 12:42
  • Thanks a lot - really appreciate your responses - cheers Brian – lyndsey May 16 '11 at 06:39

2 Answers2

4

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;

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Brian Scott
  • 9,221
  • 6
  • 47
  • 68
0

See the following anwser from Scott Hanselman. You could also put a random key in the querystring and validate the value against a list and do the necessary action if that key is no longer in your allowed users.

Community
  • 1
  • 1
Charles Byrne
  • 834
  • 2
  • 11
  • 20