By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,034 Members | 1,672 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,034 IT Pros & Developers. It's quick & easy.

Capturing and Suppressing the Backspace Key In IE

P: n/a
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
Jul 23 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a


Robert Nurse wrote:
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>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2

P: n/a
Robert Nurse wrote:
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.

--
Philip Ronan
ph***********@virgin.net
(Please remove the "z"s if replying by email)
Jul 23 '05 #3

P: n/a
Robert Nurse wrote:

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
Jul 23 '05 #4

P: n/a
JRS: In article <BD**************************@virgin.net>, dated Wed, 3
Nov 2004 16:34:39, seen in news:comp.lang.javascript, Philip Ronan
<ph***********@virgin.net> posted :
Robert Nurse wrote:

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.
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.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #5

P: n/a
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.

Brandon Blackmoor <bb********@blackgate.net> wrote in message news:<2u*************@uni-berlin.de>...
Robert Nurse wrote:

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

Jul 23 '05 #6

P: n/a
Robert Nurse wrote:
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
Jul 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.