473,320 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Capturing and Suppressing the Backspace Key In IE

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
6 15572


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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Dennis Craven | last post by:
Hello, Does anyone know how one could insert a backspace into a widget such as a TextView/Buffer in Pygtk? Whenever I try something like insert(iter, '\b') I get jibberish inserted into the...
1
by: haxmya | last post by:
Ok, made an explorer toolbar (band Object) with a textbox on it. Everything works great....except that the backspace button doesn't actually backspace when you're in the textbox. Shift-backspace...
3
by: coolsti | last post by:
Can someone help me enhance this code snippet which works only for IE so that it will also work for Firefox? I have been trying all sorts of things and have gotten to where I can capture the...
40
by: Dave Hansen | last post by:
Please note crosspost. Often when writing code requiring function pointers, it is necessary to write functions that ignore their formal parameters. For example, a state machine function might...
1
by: Blue | last post by:
This JS limits the input characters into the form. How do I modify it so that it also allows CARRIAGE RETURN and BACKSPACE (for making text correction)? Due to the template engine I am using, I...
2
by: =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post by:
I have a tabcontrol where I want to capture the CTRL+C key combination. My tabcontrol has on its tabpages some treeView controls. My intention is to intercept the event of pressing the CTRL+C when...
3
by: Bobby | last post by:
Hi I'm using Access 2003 with SQL server 2000, linked via ODBC. Can anybody tell me how to capture SQL error codes in Access? If this is not possible, is there any way I can simply turn off SQL...
5
by: Don Li | last post by:
Hi, A web app server package that I'm using includes a bunch of open source UI components (heavy with javascripts). Inevitably it has bugs, e.g. "undefined" is null or not an object. This...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.