Forum Moderators: open
Thanks,
Matthew
The script below is IE only, but possibly can be adapted for other browsers.
//Disable right mouse click Script
document.onmousedown="if (event.button==2) return false";
document.oncontextmenu=new Function("return false");
document.onkeydown = showDown;
function showDown(evt) {
evt = (evt)? evt : ((event)? event : null);
if (evt) {
if (event.keyCode == 8 && (event.srcElement.type!= "text" && event.srcElement.type!= "textarea" && event.srcElement.type!= "password")) {
// When backspace is pressed but not in form element
cancelKey(evt);
}
else if (event.keyCode == 116) {
// When F5 is pressed
cancelKey(evt);
}
else if (event.keyCode == 122) {
// When F11 is pressed
cancelKey(evt);
}
else if (event.ctrlKey && (event.keyCode == 78 ¦¦ event.keyCode == 82)) {
// When ctrl is pressed with R or N
cancelKey(evt);
}
else if (event.altKey && event.keyCode==37 ) {
// stop Alt left cursor
return false;
}
}
}
function cancelKey(evt) {
if (evt.preventDefault) {
evt.preventDefault();
return false;
}
else {
evt.keyCode = 0;
evt.returnValue = false;
}
}
There is surely a more appropriate solution..
a Pop-up that says "please for the love of God, do NOT attempt to refresh this page."
a div that loads before anything else that says "please wait for page to load... do not refresh"
I really can't think of any good reason to F with people's browsers (for the user's sake, AND for your site's sake)... and without having seen your site, I would say that your purpose is no more noble than anyone else's.
In the end, I guess it won't really matter that much if people refresh the page. It will send the data twice, and some of it may get logged twice depending on when the refresh takes place. But the end-user won't experience problems or anything; I'll just have to deal with it from an admin standpoint. When it comes right down to it, this form is going to have a limited user-base anyway. So I'm probably time ahead by just dealing with extra form data than trying to figure out a way to prevent it.
without having seen your site, I would say that your purpose is no more noble than anyone else's.
Then without having seen my site, please don't try to judge my actions. I never claimed to have a noble purpose, I just think disabling the refresh button would be justified under the circumstances. What's wrong with trying to prevent double submission of form data? It's not like I want to do this on every page of my site; it would only be for a three-page form submission and I'd simply rather get data only once per visitor. I'm pretty big on user-choice myself, so I certainly don't make a habit out of messing with their browser. But I've been on the web long enough to know a potentially valuable feature when I see one - and for this application, disabled refresh would be just that, for everyone concerned.
I would be more than happy to look at your page and prove myself wrong; unfortunately we both know that you can't post your URL, which is why I and everyone else here have to make judgments based on what you're describing. I'm surprised you would have a problem with that, given the fact that you certainly understand that this is the way the forum works.
I respect your knowledge and never insinuated that you don't know what you're doing... I'm just presenting my opinion like everyone else on this forum. If I saw a page that appeared to have trouble loading, and THEN saw that the Refresh button was deactivated, I would most likely assume my browser was acting up and I would quit the app. Hence, my post.
Good point about a disabled refresh button and quitting the process - I hadn't thought of that. I'd rather deal with duplicate form submissions than lose some submissions altogether. And I really doubt this will be much of an issue anyway, unless maybe people accidentally bump buttons or something. Thanks for sharing your insight on this.