SIDEBAR
»
S
I
D
E
B
A
R
«
How to cancel backspace key from navigating back…
March 21st, 2012 by P.G.Taboada

Don’t ask me who had the insane idea that one can navigate back when pressing the back space.

In GWT we did something like that to cancel the backspace back navigation:


3 Responses  
  • Frank Hossfeld writes:
    March 23rd, 201211:56at

    Cool, this improves usablilty.

    But, if the focus is set to something else than the body, it will not work. So, I think, it will be better to define, where the backspace is allowed and where not.

    if (as.getTagName().toLowerCase().equals(“input”) ||
    as.getTagName().toLowerCase().equals(“textarea”)) {
    // Backspace allowed
    ;
    } else {
    event.getNativeEvent().stopPropagation();
    event.getNativeEvent().preventDefault();
    }

    What do you think?

  • ABhijit Dutta writes:
    August 29th, 201204:47at

    Can we see a sample program where it was used?

  • Petar writes:
    February 22nd, 201312:03at

    Thanks for this nice part of code :)

    I changed a little bit and it works for me very nice. Here is my changes:

    Element as = Element.as(event.getNativeEvent().getEventTarget());

    boolean readOnly = as.getPropertyBoolean(“readOnly”);
    boolean contentEditable = as.getPropertyBoolean(“isContentEditable”);
    if (readOnly || !contentEditable) {
    event.getNativeEvent().stopPropagation();
    event.getNativeEvent().preventDefault();
    }


Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

SIDEBAR
»
S
I
D
E
B
A
R
«
»  Substance:WordPress   »  Style:Ahren Ahimsa
Bitnami