PREVENTING F5 REFRESH IN NETSCAPE 7.1

O

Obi Wan Shinobi

I can't seem to prevent the refresh associated with F5 in Netscape. I
can capture the key but returning false does not prevent the refresh.
The code is as follows:

function keyDown(e) {

if (navigator.appName == 'Netscape') {
if(e.which == 116) {
alert('This action is prohibited');
e.cancelBubble = true;
return false;
}

}

// IE gives me no problem at all...
if (navigator.appName == 'Microsoft Internet Explorer') {
if (window.event.keyCode == 116) {
window.event.keyCode = 0;
alert('This action is prohibited');
return false;
}
}
}

document.onkeydown = keyDown;
if (navigator.appName == 'Netscape')
document.captureEvents(Event.KEYDOWN)

Thanks in advance.
 
G

Grant Wagner

Obi said:
I can't seem to prevent the refresh associated with F5 in Netscape. I
can capture the key but returning false does not prevent the refresh.

*sighs*

You shouldn't be trying to stop the user from refreshing the browser, or
using the back button, or closing windows without logging out.

HTTP is a _stateless protocol_. Embrace the fact that HTTP-based
applications are different from stateful ones. You have much Much MUCH
less control over the client environment in which it runs.

You solve the problems of statefulness on the server, where you have
absolute control over the environment.

This means you deal with browser reloads on the server, you deal with the
possibility the user might click back on the server, you deal with
expiring user sessions on the server.

Trying to make an HTTP-based application behave like a standalone
executable leads to a lot of time spent "solving" problems which can not
be solved.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top