Jörn Nettingsmeier wrote:
[EMAIL PROTECTED] wrote:
Author: rfrovarp
Date: Fri Jul 20 10:53:59 2007
New Revision: 558075

URL: http://svn.apache.org/viewvc?view=rev&rev=558075
Log:
Prevents backspace in browsers from making the browser to go back a page.

very useful. i had never encountered this, but after checking it out on windows, it's really a major issue.

i have a minor nitpick, though:

Modified: lenya/trunk/src/modules/fckeditor/usecases/fckeditor.jx
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/fckeditor/usecases/fckeditor.jx?view=diff&rev=558075&r1=558074&r2=558075 ==============================================================================
<...>
+ <script type="text/javascript" src="/modules/editors/javascript/disablebackspace.js">&#160;</script>
<...>
-        <page:body>
+ <page:body onkeydown="return checkBackspace(event)" onkeypress="return checkBackspace(event)" >

why should we have to add two snippets to each editor?
in the o'reilly book on javascript, flanagan mentions the concept of "unobtrusive javascript", i.e. avoiding javascript snippets in the html as much as possible. i like that idea very much.

what he suggests is to register such handlers via a window.onload call that is part of the included script file, like so:

function LenyaDisableBackspace() {
  var body = document.getElementByTagName('body');
  body.onkeydown = new Function(event) {
    // checkBackspace function body here
  };
  body.onkeypress = body.onkeydown;
}
window.onload = LenyaDisableBackspace;

this has the additional benefit of using anonymous nested functions, which keep the surrounding object namespace clean (you never know if some editor might have a global checkBackspace function...)

note: this is pseudocode, i haven't tested it yet... just as food for thought.

best,

jörn


Good idea. I'm not that familiar with javascript. I am unable to get it to work on body. I can get it to work on document however. Not sure there is much of a difference in this instance between the two values.

Richard

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to