Restrict back and forward of browser buttons using javascript

murugavel.b

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

153 Views
About the Author
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};
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.