Forum Moderators: open

Message Too Old, No Replies

Disabling the back button on a web page

         

artie2004

5:36 pm on Jul 23, 2007 (gmt 0)

10+ Year Member



Hi

I am using the the following javascript to disable the back button. Is there a way that i could redirect the user to a page i.e. "newpage.html" instead of bouncing the user forward to the latest page viewed. Thanks.

<html>
<head>
<title>Back Button Demo: Page One</title>
<script>
function backButtonOverride()
{
// Work around a Safari bug
// that sometimes produces a blank page
setTimeout("backButtonOverrideBody()", 1);

}

function backButtonOverrideBody()
{
// Works if we backed up to get here
try {
history.forward();
} catch (e) {
// OK to ignore
}
// Every quarter-second, try again. The only
// guaranteed method for Opera, Firefox,
// and Safari, which don't always call
// onLoad but *do* resume any timers when
// returning to a page
setTimeout("backButtonOverrideBody()", 500);
}
</script>
</head>
<body onLoad="backButtonOverride()">
<h1>Back Button Demo: Page One</h1>
<a href="page2.html">Advance to Page Two</a>
</body>
</html>

"But I need to d

Fotiman

9:29 pm on Jul 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Disabling the back button is bad for usability, and annoying to end users. I would strongly suggest you abandon this line of thinking.

[edited by: Fotiman at 9:30 pm (utc) on July 23, 2007]