For example current page is www.google.com. But I typed a different website address in address bar and clicked. This site has fully GWT code.
But I like to back to t
try this it will work
Event.addNativePreviewHandler(new Event.NativePreviewHandler() {
@Override
public void onPreviewNativeEvent(final NativePreviewEvent event) {
if (event.getTypeInt() == Event.ONKEYDOWN) {
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_BACKSPACE) {
Element element = Element.as(event.getNativeEvent().getEventTarget());
String tagName = element.getTagName();
System.out.println(tagName);
// Add checks for other input controls
if (!tagName.equalsIgnoreCase("INPUT")
&& !tagName.equalsIgnoreCase("TEXTAREA")) {
boolean result = Window.confirm("Are you sure?");
if (!result) {
event.cancel();
}
}
}
}
}
});