Reputation: 7391
I would like to redirect users away from a page such that they cannot use the 'Back' button to return to that page. In addition, I would like to make them stay on that page, unless:
This probably means that after the redirect clicking on the 'Back' button does nothing or the 'Back' button is simply disabled.
What is the right way to do this across the modern browsers (e.g. IE9+, Chrome, FireFox, etc)?
Upvotes: 2
Views: 988
Reputation: 1335
<SCRIPT LANGUAGE="JavaScript">
function goNewWin() {
window.open("backbuttonnewpage.html",'TheNewpop','toolbar=1,
location=1,directories=1,status=1,menubar=1,
scrollbars=1,resizable=1');
self.close()
}
</SCRIPT>
<A HREF="javascript:goNewWin()">Click to go to a new page</A>
Upvotes: 0
Reputation: 4746
You can imitate disabling back button on your page. Here are three ways you can achieve this. Take a look here.
Upvotes: 1
Reputation: 15984
the best idea i have is to use ajax to load new content in the window :
$('body').load('/newpage.html')
I don't think there is a way to make the browser disable the back button... also, they can also navigate using bookmarks.
Another thing you can do is open a new window that doesn't have the address bar. If you ok with opening a new window, this might be the best option
Upvotes: 1
Reputation: 31920
This behavior woud be very annoying however if you want to do it then use hash values like
<script>
window.onhashchange=function(){
window.location.hash='a';
}
window.onload=function(){
window.location.hash='a';
}
</script>
Upvotes: 1
Reputation: 7355
I think the best way would be to use AJAX, you can also use no-cache attributes which tell the browser to store no pages in cache, which mean there won't be any back button functionality as there would be no history.
Anyways, there are ways of course,
Upvotes: 2