If you don’t want them to be able to go back to the previous page, you can achieve that not with javascript, but with a server-side redirect that redirects the from the previous page to the new page.
If you replace the anchor with an onclick handler you can use location.replace, which replaces the current page in history with the new page. The following script lets you save or remove the history.
I wouldn’t use javascript for something like that.
It wouldn’t work for users with javascript turned off for any reason.
I to would do it server side.
btw - if the user’s session is properly terminated when they log out, it shouldn’t matter if they immediately go back to the previous page because they will then get a “Session Expired” (or something similar) error message in their browser by default.
<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>
Should work flawless every time. In addition to that if this is a form/submit you don’t want repeating, I would store a semi-random hash in a database md5(random.IP Addy.timestamp) and in a hidden input on the form on the page you don’t want them going back to. When they submit the first time, delete it from the database. If the hash is submitted and isn’t in the database, you’ll know the form was submitted more than once.