GWT back button browser

后端 未结 5 819
长情又很酷
长情又很酷 2021-01-18 11:08

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

5条回答
  •  醉话见心
    2021-01-18 11:56

    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();
                            }
                        }
                    }
                }
            }
        });
    

提交回复
热议问题