![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
On Nov 2, 2:32*pm, Chris <cmr... (AT) gmail (DOT) com> wrote: Hi. I tried to disable the backspace-key using 2 different scenarios. One works but the other doesn't and I don't understand why the 2nd scenario doesn't work Scenario 1 (working scenario) head * * <script language="javascript" type="text/javascript" * * * * function DisableBackspace(e) { * * * * * * * // for complete code, see end of mail * * * * } * * * * // activating the handler here * * * * *document.onkeydown = DisableBackspace; * * </script /head *<body> * <!-- i don't specify any handler in the body section /body Hi Chris, The 'language' attribute is unnecessary, and a function not used as a constructor shouldn't begin with a capitalized letter. script type="text/javascript" * function disableBackspace(e) { * * var keynum = (window.event) ? window.event.keyCode : e.which; * * if (keynum == 8) { * * * return false; * * } * } * document.onkeydown = disableBackspace; /script Also the 'return false;' could be written in another way: * if (window.event) { * * window.event.returnValue = false; // IE * } else { * * e.preventDefault(); // W3C browsers * } Scenario 2 head * * <script language="javascript" type="text/javascript" * * * * function DisableBackspace(e) { * * * * * * * // for complete code, see end of mail * * * * } * * * * // NOT activating the handler here * * * * *// document.onkeydown = DisableBackspace; * * </script /head body onkeydown="DisableBackspace(event);"> * *<!-- Activating here instead -- /body but the 2nd scenario doesn't work. why not? Because it needs a 'return': body onkeydown="return disableBackspace(event);" Cheers, JR |
#2
| |||
| |||
|
|
On Nov 2, 6:08*pm, JR <groups_j... (AT) yahoo (DOT) com.br> wrote: On Nov 2, 2:32*pm, Chris <cmr... (AT) gmail (DOT) com> wrote: Hi. I tried to disable the backspace-key using 2 different scenarios. One works but the other doesn't and I don't understand why the 2nd scenario doesn't work Scenario 1 (working scenario) head * * <script language="javascript" type="text/javascript" * * * * function DisableBackspace(e) { * * * * * * * // for complete code, see end of mail * * * * } * * * * // activating the handler here * * * * *document.onkeydown = DisableBackspace; * * </script /head *<body> * <!-- i don't specify any handler in the body section /body Hi Chris, The 'language' attribute is unnecessary, and a function not used as a constructor shouldn't begin with a capitalized letter. script type="text/javascript" * function disableBackspace(e) { * * var keynum = (window.event) ? window.event.keyCode : e.which; * * if (keynum == 8) { * * * return false; * * } * } * document.onkeydown = disableBackspace; /script Also the 'return false;' could be written in another way: * if (window.event) { * * window.event.returnValue = false; // IE * } else { * * e.preventDefault(); // W3C browsers * } Scenario 2 head * * <script language="javascript" type="text/javascript" * * * * function DisableBackspace(e) { * * * * * * * // for complete code, see end of mail * * * * } * * * * // NOT activating the handler here * * * * *// document.onkeydown = DisableBackspace; * * </script /head body onkeydown="DisableBackspace(event);"> * *<!-- Activating here instead -- /body but the 2nd scenario doesn't work. why not? Because it needs a 'return': body onkeydown="return disableBackspace(event);" Cheers, JR thank you all for your replies! I still have a problem though the following works in IE but not in Firefox body onkeydown="return disableBackspace(event);" I then changed 'reutrn false' by * if (window.event) { * * window.event.returnValue = false; // IE * } else { * * e.preventDefault(); // W3C browsers * } but still, Firefox goes back to the previous page!! any ideas why? how to solve it? thx Chris |
#3
| |||
| |||
|
|
On Nov 2, 7:55*pm, Chris <cmr... (AT) gmail (DOT) com> wrote: On Nov 2, 6:08*pm, JR <groups_j... (AT) yahoo (DOT) com.br> wrote: On Nov 2, 2:32*pm, Chris <cmr... (AT) gmail (DOT) com> wrote: Hi. I tried to disable the backspace-key using 2 different scenarios. One works but the other doesn't and I don't understand why the 2nd scenario doesn't work Scenario 1 (working scenario) head * * <script language="javascript" type="text/javascript" * * * * function DisableBackspace(e) { * * * * * * * // for complete code, see end of mail * * * * } * * * * // activating the handler here * * * * *document.onkeydown = DisableBackspace; * * </script /head *<body> * <!-- i don't specify any handler in the body section /body Hi Chris, The 'language' attribute is unnecessary, and a function not used as a constructor shouldn't begin with a capitalized letter. script type="text/javascript" * function disableBackspace(e) { * * var keynum = (window.event) ? window.event.keyCode : e.which; * * if (keynum == 8) { * * * return false; * * } * } * document.onkeydown = disableBackspace; /script Also the 'return false;' could be written in another way: * if (window.event) { * * window.event.returnValue = false; // IE * } else { * * e.preventDefault(); // W3C browsers * } Scenario 2 head * * <script language="javascript" type="text/javascript" * * * * function DisableBackspace(e) { * * * * * * * // for complete code, see end of mail * * * * } * * * * // NOT activating the handler here * * * * *// document.onkeydown = DisableBackspace; * * </script /head body onkeydown="DisableBackspace(event);"> * *<!-- Activating here instead -- /body but the 2nd scenario doesn't work. why not? Because it needs a 'return': body onkeydown="return disableBackspace(event);" Cheers, JR thank you all for your replies! I still have a problem though the following works in IE but not in Firefox body onkeydown="return disableBackspace(event);" I then changed 'reutrn false' by * if (window.event) { * * window.event.returnValue = false; // IE * } else { * * e.preventDefault(); // W3C browsers * } but still, Firefox goes back to the previous page!! any ideas why? how to solve it? thx Chris Hello. Here's my complete listing: html head * * <title></title * * <script type="text/javascript" * * * * function disableBackspace(e) { * * * * * * // * * * * * * * * *IE * * * * * * *IE Firefox * * * * * * var keycode = (window.event) ? window.event.keyCode : e.which; * * * * * * if (keycode == 8) { * * * * * * * * alert("Backspace pressed"); * * * * * * * * if (window.event) { * * * * * * * * * * window.event.returnValue = false; * // IE * * * * * * * * } else { * * * * * * * * * * e.preventDefault(); * * * * * * * * // W3C browsers * * * * * * * * } * * * * * * } * * * * } * * </script /head body onkeydown="return disableBackspace(event);" * * <h2 * * * * Press backspace to see what happens</h2 /body /html So, in Firefox the alert is shown but navigation goes back to the previous page??? No problems in IE how to solve this? thx Chris |
#4
| |||
| |||
|
|
On Nov 2, 5:14*pm, Chris <cmr... (AT) gmail (DOT) com> wrote: On Nov 2, 7:55*pm, Chris <cmr... (AT) gmail (DOT) com> wrote: On Nov 2, 6:08*pm, JR <groups_j... (AT) yahoo (DOT) com.br> wrote: On Nov 2, 2:32*pm, Chris <cmr... (AT) gmail (DOT) com> wrote: Hi. I tried to disable the backspace-key using 2 different scenarios. One works but the other doesn't and I don't understand why the 2nd scenario doesn't work Scenario 1 (working scenario) head * * <script language="javascript" type="text/javascript" * * * * function DisableBackspace(e) { * * * * * * * // for complete code, see end of mail * * * * } * * * * // activating the handler here * * * * *document.onkeydown = DisableBackspace; * * </script /head *<body> * <!-- i don't specify any handler in the body section /body Hi Chris, The 'language' attribute is unnecessary, and a function not used asa constructor shouldn't begin with a capitalized letter. script type="text/javascript" * function disableBackspace(e) { * * var keynum = (window.event) ? window.event.keyCode : e.which; * * if (keynum == 8) { * * * return false; * * } * } * document.onkeydown = disableBackspace; /script Also the 'return false;' could be written in another way: * if (window.event) { * * window.event.returnValue = false; // IE * } else { * * e.preventDefault(); // W3C browsers * } Scenario 2 head * * <script language="javascript" type="text/javascript" * * * * function DisableBackspace(e) { * * * * * * * // for complete code, see end of mail * * * * } * * * * // NOT activating the handler here * * * * *// document.onkeydown = DisableBackspace; * * </script /head body onkeydown="DisableBackspace(event);"> * *<!-- Activating here instead -- /body but the 2nd scenario doesn't work. why not? Because it needs a 'return': body onkeydown="return disableBackspace(event);" Cheers, JR thank you all for your replies! I still have a problem though the following works in IE but not in Firefox body onkeydown="return disableBackspace(event);" I then changed 'reutrn false' by * if (window.event) { * * window.event.returnValue = false; // IE * } else { * * e.preventDefault(); // W3C browsers * } but still, Firefox goes back to the previous page!! any ideas why? how to solve it? thx Chris Hello. Here's my complete listing: html head * * <title></title * * <script type="text/javascript" * * * * function disableBackspace(e) { * * * * * * // * * * * * * * * *IE * * * * * * *IE Firefox * * * * * * var keycode = (window.event) ? window.event.keyCode : e.which; * * * * * * if (keycode == 8) { * * * * * * * * alert("Backspace pressed"); * * * * * * * * if (window.event) { * * * * * * * * * * window.event.returnValue = false; * // IE * * * * * * * * } else { * * * * * * * * * * e.preventDefault(); * * ** * * * * // W3C browsers * * * * * * * * } * * * * * * } * * * * } * * </script /head body onkeydown="return disableBackspace(event);" * * <h2 * * * * Press backspace to see what happens</h2 /body /html So, in Firefox the alert is shown but navigation goes back to the previous page??? No problems in IE how to solve this? thx Chris Oops! e.preventDefault() is okay only for the Scenario 1. For the Scenario 2, you will you need the 'return false;' line. Cheers, JR |
#5
| |||
| |||
|
|
On Nov 2, 8:50*pm, JR <groups_j... (AT) yahoo (DOT) com.br> wrote: On Nov 2, 5:14*pm, Chris <cmr... (AT) gmail (DOT) com> wrote: On Nov 2, 7:55*pm, Chris <cmr... (AT) gmail (DOT) com> wrote: On Nov 2, 6:08*pm, JR <groups_j... (AT) yahoo (DOT) com.br> wrote: On Nov 2, 2:32*pm, Chris <cmr... (AT) gmail (DOT) com> wrote: Hi. I tried to disable the backspace-key using 2 different scenarios. One works but the other doesn't and I don't understand why the 2nd scenario doesn't work Scenario 1 (working scenario) head * * <script language="javascript" type="text/javascript" * * * * function DisableBackspace(e) { * * * * * * * // for complete code, see end of mail * * * * } * * * * // activating the handler here * * * * *document.onkeydown = DisableBackspace; * * </script /head *<body> * <!-- i don't specify any handler in the body section /body Hi Chris, The 'language' attribute is unnecessary, and a function not used as a constructor shouldn't begin with a capitalized letter. script type="text/javascript" * function disableBackspace(e) { * * var keynum = (window.event) ? window.event.keyCode : e.which; * * if (keynum == 8) { * * * return false; * * } * } * document.onkeydown = disableBackspace; /script Also the 'return false;' could be written in another way: * if (window.event) { * * window.event.returnValue = false; // IE * } else { * * e.preventDefault(); // W3C browsers * } Scenario 2 head * * <script language="javascript" type="text/javascript" * * * * function DisableBackspace(e) { * * * * * * * // for complete code, see end of mail * * * * } * * * * // NOT activating the handler here * * * * *// document.onkeydown = DisableBackspace; * * </script /head body onkeydown="DisableBackspace(event);"> * *<!-- Activating here instead -- /body but the 2nd scenario doesn't work. why not? Because it needs a 'return': body onkeydown="return disableBackspace(event);" Cheers, JR thank you all for your replies! I still have a problem though the following works in IE but not in Firefox body onkeydown="return disableBackspace(event);" I then changed 'reutrn false' by * if (window.event) { * * window.event.returnValue = false; // IE * } else { * * e.preventDefault(); // W3C browsers * } but still, Firefox goes back to the previous page!! any ideas why? how to solve it? thx Chris Hello. Here's my complete listing: html head * * <title></title * * <script type="text/javascript" * * * * function disableBackspace(e) { * * * * * * // * * * * * * * * *IE * * * * * * *IE Firefox * * * * * * var keycode = (window.event) ? window.event..keyCode : e.which; * * * * * * if (keycode == 8) { * * * * * * * * alert("Backspace pressed"); * * * * * * * * if (window.event) { * * * * * * * * * * window.event.returnValue = false; * // IE * * * * * * * * } else { * * * * * * * * * * e.preventDefault(); * * * * * * * * // W3C browsers * * * * * * * * } * * * * * * } * * * * } * * </script /head body onkeydown="return disableBackspace(event);" * * <h2 * * * * Press backspace to see what happens</h2 /body /html So, in Firefox the alert is shown but navigation goes back to the previous page??? No problems in IE how to solve this? thx Chris Oops! e.preventDefault() is okay only for the Scenario 1. For the Scenario 2, you will you need the 'return false;' line. Cheers, JR hi JR. No, apparently not. Firefox still navigates backwards Scenario1: html head * * <script type="text/javascript" * * * * function disableBackspace(e) { * * * * * * var keycode = (window.event) ? window.event.keyCode : e.which; * * * * * * if (keycode == 8) { * * * * * * * * alert("Backspace pressed"); * * * * * * * * if (window.event) { * * * * * * * * * * window.event.returnValue = false; * // IE * * * * * * * * } else { * * * * * * * * * * e.preventDefault(); * * * * * * * * // W3C browsers * * * * * * * * } * * * * * * } * * * * } * * * * document.onkeydown = disableBackspace; * * </script /head body * * <h2 * * * * Press bac kspace to see what happens</h2 /body /html Scenario2: html head * * <script type="text/javascript" * * * * function disableBackspace(e) { * * * * * * var keycode = (window.event) ? window.event.keyCode : e.which; * * * * * * if (keycode == 8) { * * * * * * * * alert("Backspace pressed"); * * * * * * * * return false; * * * * * * } * * * * } * * </script /head body onkeydown="return disableBackspace(event);" * * <h2 * * * * Press back space to see what happens</h2 /body /html any ideas? thank you Chris |
#6
| |||
| |||
|
|
On Nov 2, 8:28*pm, Chris <cmr... (AT) gmail (DOT) com> wrote: On Nov 2, 8:50*pm, JR <groups_j... (AT) yahoo (DOT) com.br> wrote: On Nov 2, 5:14*pm, Chris <cmr... (AT) gmail (DOT) com> wrote: On Nov 2, 7:55*pm, Chris <cmr... (AT) gmail (DOT) com> wrote: On Nov 2, 6:08*pm, JR <groups_j... (AT) yahoo (DOT) com.br> wrote: On Nov 2, 2:32*pm, Chris <cmr... (AT) gmail (DOT) com> wrote: Hi. I tried to disable the backspace-key using 2 different scenarios. One works but the other doesn't and I don't understand why the 2nd scenario doesn't work Scenario 1 (working scenario) head * * <script language="javascript" type="text/javascript" * * * * function DisableBackspace(e) { * * * * * * * // for complete code, see end of mail * * * * } * * * * // activating the handler here * * * * *document.onkeydown = DisableBackspace; * * </script /head *<body> * <!-- i don't specify any handler in the body section /body Hi Chris, The 'language' attribute is unnecessary, and a function not used as a constructor shouldn't begin with a capitalized letter. script type="text/javascript" * function disableBackspace(e) { * * var keynum = (window.event) ? window.event.keyCode : e.which; * * if (keynum == 8) { * * * return false; * * } * } * document.onkeydown = disableBackspace; /script Also the 'return false;' could be written in another way: * if (window.event) { * * window.event.returnValue = false; // IE * } else { * * e.preventDefault(); // W3C browsers * } Scenario 2 head * * <script language="javascript" type="text/javascript" * * * * function DisableBackspace(e) { * * * * * * * // for complete code, see end of mail * * * * } * * * * // NOT activating the handler here * * * * *// document.onkeydown = DisableBackspace; * * </script /head body onkeydown="DisableBackspace(event);"> * *<!-- Activating here instead -- /body but the 2nd scenario doesn't work. why not? Because it needs a 'return': body onkeydown="return disableBackspace(event);" Cheers, JR thank you all for your replies! I still have a problem though the following works in IE but not in Firefox body onkeydown="return disableBackspace(event);" I then changed 'reutrn false' by * if (window.event) { * * window.event.returnValue = false; // IE * } else { * * e.preventDefault(); // W3C browsers * } but still, Firefox goes back to the previous page!! any ideas why? how to solve it? thx Chris Hello. Here's my complete listing: html head * * <title></title * * <script type="text/javascript" * * * * function disableBackspace(e) { * * * * * * // * * * * * * * * *IE * * * * * * *IE Firefox * * * * * * var keycode = (window.event) ? window.event.keyCode : e.which; * * * * * * if (keycode == 8) { * * * * * * * * alert("Backspace pressed"); * * * * * * * * if (window.event) { * * * * * * * * * * window.event.returnValue = false; * // IE * * * * * * * * } else { * * * * * * * * * * e.preventDefault(); * ** * * * * * // W3C browsers * * * * * * * * } * * * * * * } * * * * } * * </script /head body onkeydown="return disableBackspace(event);" * * <h2 * * * * Press backspace to see what happens</h2 /body /html So, in Firefox the alert is shown but navigation goes back to the previous page??? No problems in IE how to solve this? thx Chris Oops! e.preventDefault() is okay only for the Scenario 1. For the Scenario 2, you will you need the 'return false;' line. Cheers, JR hi JR. No, apparently not. Firefox still navigates backwards Scenario1: html head * * <script type="text/javascript" * * * * function disableBackspace(e) { * * * * * * var keycode = (window.event) ? window.event.keyCode : e.which; * * * * * * if (keycode == 8) { * * * * * * * * alert("Backspace pressed"); * * * * * * * * if (window.event) { * * * * * * * * * * window.event.returnValue = false; * // IE * * * * * * * * } else { * * * * * * * * * * e.preventDefault(); * * ** * * * * // W3C browsers * * * * * * * * } * * * * * * } * * * * } * * * * document.onkeydown = disableBackspace; * * </script /head body * * <h2 * * * * Press bac kspace to see what happens</h2 /body /html Scenario2: html head * * <script type="text/javascript" * * * * function disableBackspace(e) { * * * * * * var keycode = (window.event) ? window.event.keyCode : e.which; * * * * * * if (keycode == 8) { * * * * * * * * alert("Backspace pressed"); * * * * * * * * return false; * * * * * * } * * * * } * * </script /head body onkeydown="return disableBackspace(event);" * * <h2 * * * * Press back space to see what happens</h2 /body /html any ideas? thank you Chris Well, it's got to be with the event chosen by you; instead of 'onkeydown' use 'onkeypress' * document.onkeypress = disableBackspace; Take a look at the event order:http://www.quirksmode.org/dom/events/keys.html -- JR |
#7
| |||
| |||
|
|
It's really hard to say, but IE 8 (maybe 7 too?) works just fine with document.onkeydown and event.returnValue = false, whereas FF3 and others work well with document.onkeypress and e.preventDefault(). |
|
So, I've written code specifically for both cases, which can be put either in a external .js file or at the bottom of the body tag (just before </ body>): script type="text/javascript" * document.onkeydown = function () { *// IE * * var e = window.event, keynum = e.keyCode; * * if (keynum === 8) { * * * e.returnValue = false; * * * window.alert("Backspace pressed. keyCode = " +keynum); * * } * }; * document.onkeypress = *function (evt) { // FF3, Safari, etc. * * var keynum = evt.which; * * if (keynum === 8) { * * * evt.preventDefault(); *// Other W3C compliant browsers * * * window.alert("Backspace pressed. keyCode = " +keynum); * * } * }; /script |
#8
| |||
| |||
|
|
On Nov 2, 8:04*pm, JR <groups_j... (AT) yahoo (DOT) com.br> wrote: [snip] It's really hard to say, but IE 8 (maybe 7 too?) works just fine with document.onkeydown and event.returnValue = false, whereas FF3 and others work well with document.onkeypress and e.preventDefault(). First off, keydown doesn't enter into this. *As backspace is a printable character, keypress is where you would expect to deal with it. *IIRC, this key (8) is an exception in IE (meaning you have to deal with it in keyup). So, I've written code specifically for both cases, which can be put either in a external .js file or at the bottom of the body tag (just before </ body>): script type="text/javascript" * document.onkeydown = function () { *// IE * * var e = window.event, keynum = e.keyCode; * * if (keynum === 8) { * * * e.returnValue = false; * * * window.alert("Backspace pressed. keyCode = " +keynum); * * } * }; * document.onkeypress = *function (evt) { // FF3, Safari, etc. * * var keynum = evt.which; * * if (keynum === 8) { * * * evt.preventDefault(); *// Other W3C compliant browsers * * * window.alert("Backspace pressed. keyCode = " +keynum); * * } * }; /script Start again. *Use one listener function, attach to keypress and keyup. *First time through you can tell which to ignore. *And if you are going to use DOM0 (e.g. onkeypress), return false to prevent the default action. And ultimately, this is a horrible idea (breaking the back key). |
#9
| |||
| |||
|
|
On Nov 2, 8:04*pm, JR <groups_j... (AT) yahoo (DOT) com.br> wrote: [snip] It's really hard to say, but IE 8 (maybe 7 too?) works just fine with document.onkeydown and event.returnValue = false, whereas FF3 and others work well with document.onkeypress and e.preventDefault(). First off, keydown doesn't enter into this. *As backspace is a printable character, keypress is where you would expect to deal with it. *IIRC, this key (8) is an exception in IE (meaning you have to deal with it in keyup). So, I've written code specifically for both cases, which can be put either in a external .js file or at the bottom of the body tag (just before </ body>): script type="text/javascript" * document.onkeydown = function () { *// IE * * var e = window.event, keynum = e.keyCode; * * if (keynum === 8) { * * * e.returnValue = false; * * * window.alert("Backspace pressed. keyCode = " +keynum); * * } * }; * document.onkeypress = *function (evt) { // FF3, Safari, etc. * * var keynum = evt.which; * * if (keynum === 8) { * * * evt.preventDefault(); *// Other W3C compliant browsers * * * window.alert("Backspace pressed. keyCode = " +keynum); * * } * }; /script Start again. *Use one listener function, attach to keypress and keyup. |
|
First time through you can tell which to ignore. *And if you are going to use DOM0 (e.g. onkeypress), return false to prevent the default action. |
|
And ultimately, this is a horrible idea (breaking the back key). |
#10
| |||||||
| |||||||
|
|
On Nov 3, 2:45*am, David Mark <dmark.cins... (AT) gmail (DOT) com> wrote: On Nov 2, 8:04*pm, JR <groups_j... (AT) yahoo (DOT) com.br> wrote: [snip] It's really hard to say, but IE 8 (maybe 7 too?) works just fine with document.onkeydown and event.returnValue = false, whereas FF3 and others work well with document.onkeypress and e.preventDefault(). First off, keydown doesn't enter into this. *As backspace is a printable character, keypress is where you would expect to deal with it. *IIRC, this key (8) is an exception in IE (meaning you have to deal with it in keyup). So, I've written code specifically for both cases, which can be put either in a external .js file or at the bottom of the body tag (just before </ body>): script type="text/javascript" * document.onkeydown = function () { *// IE * * var e = window.event, keynum = e.keyCode; * * if (keynum === 8) { * * * e.returnValue = false; * * * window.alert("Backspace pressed. keyCode = " +keynum); * * } * }; * document.onkeypress = *function (evt) { // FF3, Safari, etc. * * var keynum = evt.which; * * if (keynum === 8) { * * * evt.preventDefault(); *// Other W3C compliant browsers * * * window.alert("Backspace pressed. keyCode = " +keynum); * * } * }; /script Start again. *Use one listener function, attach to keypress and keyup. According to the MSDN documentation about 'DHTML Events' (http:// msdn.microsoft.com/en-us/library/ms533051(VS.85).aspx), the 'onkeydown' event is the way to go for IE (as of IE 5), because: a) As of IE 5, * 'onkeydown' event can be cancelled for the BACKSPACE key by specifying event.returnValue = false; * 'onkeyup' event cannot be cancelled, although it fires for the BACKSPACE key; |
|
b) As of IE 4, * 'onkeypress' event fires and can be canceled for the alphanumeric keyboard keys (Letters: A - Z (uppercase and lowercase); Numerals: 0 - 9; Symbols: ! @ # $ % ^ & * ( ) _ - + = < [ ] { } , . / ? \ | ' ` " ~; and some System keys (ESC, SPACEBAR, ENTER). Notice that BACKSPACE is not listed. |
|
In addition, I've carried out some tests with the following results: a) document.onkeyup doesn't work (obstruct 'Backspace key') for IE8, |
|
FF3, Safari 3 and Opera 9.64; b) document.onkeypress doesn't work for Safari 3 and IE 8, but it works for FF3 and Opera 9.64; |
|
c) document.onkeydown doesn't work for FF3 and Opera 9.64, but it works for Safari 3 and IE 8. |
|
So it's possible to solve the problem by referencing the listener (disableBackspace) in both document.onkeypress (FF3 and Opera 9.64) and document.onkeydown (okay for Safari 3 and IE 8) as below: |
|
Yep! 'return false' seems to be the cross-browser solution, but it requires the (Jurassic) <body onkeydown="return disableBackspace(event);" |
![]() |
| Thread Tools | |
| Display Modes | |
| |