问题描述
从一个班级导航到另一个班级创建历史记录时,我有两个班级。现在,我想通过确认用户是否想离开页面来提示用户。现在,我尝试在<$ c $中使用 Window.closingHandler()
c> gwt 但它不适用于退格按钮和浏览器后退按钮,它只能在关闭整个浏览器或使用交叉的特定页面上工作。它也用于重新加载。
我也尝试过使用Javascript,它使用 onbeforeunload()
。 / p>
以下是我使用的代码。
JAVASCRIPT:
window.onbeforeunload = function(){
return你确定要离开这个令人愉快的页面吗?;
}
以及gwt中的其他代码:
Window.addWindowClosingHandler(new Window.ClosingHandler(){
public void onWindowClosing(ClosingEvent event){
event.setMessage(Do you want关闭?);
System.out.println(Closing ...);
}
});
我希望在 gwt
。
我在JSNI中得到了这个,但它也不能在浏览器后退按钮中使用。
public native void call()/ * - {
$ wnd.onkeypress = GetChar;
函数GetChar(event)
{
var key = event.keyCode;
var bb = event.target.nodeName;
if(key == 8&& bb ==BODY)
{
var x = window.confirm(你确定要离开页面);
if(x == true)
{
window.history.back();
}
else if(x == false)
{
return false;
}
}
}
} - * /;
I have two classes when navigating from one class to another created history. Now, I want to prompt the user by a confirm whether user wants to leave the page or not.Till now , I tried using Window.closingHandler()
in gwt
but its not working for backspace button and browser back button its only working on closing the entire browser or that particular page using cross. Its also working on reload.
I have also tried on Javascript and it worked perfect using onbeforeunload()
.
Here are the codes I used.
JAVASCRIPT:
window.onbeforeunload = function () {
return "Are you sure you wish to leave this delightful page?";
}
And the other code in gwt:
Window.addWindowClosingHandler(new Window.ClosingHandler() {
public void onWindowClosing(ClosingEvent event) {
event.setMessage("Do you wanna close?");
System.out.println("Closing...");
}
});
I want it to be done in gwt
.
I have got this in JSNI, But its also not working in browser back button..
public native void call()/*-{
$wnd.onkeypress = GetChar;
function GetChar (event)
{
var key = event.keyCode;
var bb = event.target.nodeName;
if(key==8 && bb=="BODY")
{
var x= window.confirm("Are you sureyou want to leave the page");
if (x==true)
{
window.history.back();
}
else if(x==false)
{
return false;
}
}
}
}-*/;
这篇关于以gwt退格提示用户和浏览器后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!