Pages

Tuesday, August 25, 2009

Diable Browser Back Button

I have gone mad for getting my browser back button disabled in one of my projects. And at last arrived at this solution:

function disableBrowserBackBtn() { window.history.go(1) }
disableBrowserBackBtn();
window.onload = disableBrowserBackBtn();
window.onpageshow = function(evt) { if (evt.persisted) disableBrowserBackBtn() }
window.onunload = function() { void (0); disableBrowserBackBtn(); }

You have to just add the Script in the pages you want to disable the browser back button.

But this is just bluffing the user, using the the javascript code window.hsitory.go(-1) ->Redirecting to previous page.

For the perfect solution you have to open a new pop-up window with no navigation toolbar.

Please let me know your comments....Have a good day.

No comments:

Post a Comment