Search This Blog

Monday, September 10, 2012

BackButton-Disable by JavaScript code

<script language="JavaScript">
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";
}
</script>

No comments :