954,566 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

Restrict back and forward of browser buttons using javascript

By Murugavel on Jan 5th, 2010 7:14 pm

If you want to restrict the user to go back or forward from the web browser, you can use the below mentioned javascript. Use this javascript in the script tag. It works on all browsers.

For further details:

http://dotnetbypulikesi.blogspot.com

function defeatIE()
{
if (document.all)
{
(message);return false;
}
}
function defeatNS(e)
{
if
(document.layers||(document.getElementById&&!document.all))
{
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{
document.captureEvents(Event.MOUSEDOWN);document.onmousedown=defeatNS;
}
else
{
document.onmouseup=defeatNS;document.oncontextmenu=defeatIE;
}
document.oncontextmenu=new Function("return false")
function preventBack()
{
window.history.forward();
}
setTimeout("preventBack()", 0);
window.onunload=function(){null};

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: