views:

49

answers:

3

I'm making a static HTML demo that emulates the behavior of a web portal that logs you out when you press the back button.

How might one do this using javascript? Is it possible?

+5  A: 

It is generally considered bad form to override the behavior of the Back button.

el chief
This is a common customer requirement, though.
David
Agreed. It seems rude and also confusing to thwart the user's expecations of what the back button does. Why not have a "logout" button?
Nathan Long
I know.. it pains me to aim to do this, but it's for a usability test to hopefully prove that this function needs to be changed in the actual system!
Jane
A: 

You can use cookies to send a value between pages. For the demo, the logout page could set a "LoggedOut=1" cookie. Then in the top of all of your site's pages, have javascript that checks for the cookie. If set, redirect the user to the home page. The trick is that you have to use javascript to handle the redirect since the script has to already be in the user's browser cache.

Note that this doesn't add any security to the app. It just adds a layer of obfuscation.

David
A: 

It is possible to hack with iframe element to hijack previous entry in the browser history, so single click of back button will return to 'not logged in' state. GMail uses that heavily, thats why they still have 'basic HTML' webmail UI.