473,395 Members | 1,996 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,395 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 15578


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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.