开发者

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


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;


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜