cancel
Showing results for 
Search instead for 
Did you mean: 

javascript for disabling the back button in the browser

Former Member
0 Kudos

Hi All,

i want to disable the back button appearing the toolbar in the browser. I either want to disable or hide that button or on clicking on the back button i want to remain on the same page.

I have tried using window.history.forward(1);, Now when i click on the back button it doesn't allow me to move back instead keep me on the same page. This thing works fine in IE but now i want to have the same functionality in case of Mozilla. can anyone help me with some javascript or any other option.

Thanks.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

This will work with Mozilla firefox:

This will allow you to turn the back buttons function off with the functions ‘blockBackButton()’

And turn it on again with ‘resetBackButton()’

The script uses the get part of the url, but wont permanently change it because if the browser get a changed get part of the url, the script will reload the earlier page where the url was unchanged.

var ie = (window.navigator.appName == "Microsoft Internet Explorer") ? true : false;

function setEventByObject(object, event, func){

if (!ie){

object.addEventListener(event, func, false);

} else {

object.attachEvent("on" + event, func);

}

}

setEventByObject(win, "unload", exitme);

var block = "false";

function blockBackButton(){

block = "true";

}

function resetBackButton(){

block = "false";

}

function jumpforward(){

if(window.location.href.indexOf("&jumpforward")!=-1) {

history.forward();

}

}

jumpforward();

function exitme(){

if(block == "true") window.location.href += "&jumpforward";

}

eddy_declercq
Active Contributor
0 Kudos

Hi,

Check this web log

/people/sergio.ferrari2/blog/2005/04/18/bsp-howto-back-navigation--the-nightmare-of-statefull-web-applications

Eddy