Capturing and Suppressing the Backspace Key In IE

R

Robert Nurse

Hi,

Is it at all possible to capture and suppress the backspace key when
focus is not on a form edit control? Basically, while the page is
loading I don't want the user pressing the backspace key which IE
interprets as a desire to return to the previous page.

Thanks
 
M

Martin Honnen

Robert said:
Is it at all possible to capture and suppress the backspace key when
focus is not on a form edit control? Basically, while the page is
loading I don't want the user pressing the backspace key which IE
interprets as a desire to return to the previous page.

<html lang="en">
<head>
<title>capturing and cancelling the backspace key</title>
<script type="text/javascript">
document.onkeydown = document.onkeypress = function (evt) {
if (typeof evt == 'undefined') {
evt = window.event;
}
if (evt) {
var keyCode = evt.keyCode ? evt.keyCode : evt.charCode;
if (keyCode == 8) {
if (evt.preventDefault) {
evt.preventDefault();
}
return false;
}
else {
return true;
}
}
else {
return true;
}
}
</script>
</head>
<body>
<p>Is the backspace key cancelled?</p>
</body>
</html>
 
P

Philip Ronan

Robert said:
Hi,

Is it at all possible to capture and suppress the backspace key when
focus is not on a form edit control? Basically, while the page is
loading I don't want the user pressing the backspace key which IE
interprets as a desire to return to the previous page.

Thanks

Perhaps, but why do you want to do this? If you find IE annoying then use a
different browser. Disabling navigation features like this is not going to
improve the accessibility of your website.
 
B

Brandon Blackmoor

Robert said:
Is it at all possible to capture and suppress the
backspace key when focus is not on a form edit control?

Rule #1: DO NOT INTERFERE WITH THE OPERATION OF THE USER'S WEB BROWSER.

Do not suppress or override key presses. Do not suppress or override
mouse clicks. Do not hide the menu. Do not overwrite the status text.

Just because something is possible does not mean that it should be done.
The above should almost never, if ever, be done.

This is not a flame. It is a warning.

bblackmoor
2004-11-03
 
D

Dr John Stockton

JRS: In article <BDAEB91F.251A6%[email protected]>, dated Wed, 3
Nov 2004 16:34:39, seen in Philip Ronan
Perhaps, but why do you want to do this? If you find IE annoying then use a
different browser. Disabling navigation features like this is not going to
improve the accessibility of your website.

On the Internet, an author does not get to choose the user's browser -
unless he is prepared to write pages of restricted compatibility. An
author should want, as far is possible, to prevent unfortunate effects
from user actions. The real question is whether the gains from making
such a change to the user interface would outweigh the losses.
 
R

Robert Nurse

It is when it's a closed system and you have Fed users who want things
a certain way no matter what you tell them. It'd be too long and
laborious to explain my situation. All I can say is, I work for a
tough crowd :). They (even I) wasn't aware of this "feature" before
we ran into it by accident.
 
B

Brandon Blackmoor

Robert said:
It is when it's a closed system and you have Fed users
who want things a certain way no matter what you tell
them.

Tell them that interfering with the user's web browser in that fashion
violates the requirements of Section 508, with which all US Federal
agencies are required to comply, and that you have no choice in the matter.

Being an expert in your field is the best defense against being asked to
do something stupid.

bblackmoor
2004-11-03
 

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

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top