我如何处理页面上的 "refresh" 事件?
How can i handle "refresh" event on my page?
我想在用户单击 "refresh" 后显示一个确认弹出窗口 "Do you want to refresh this page"。如果用户在弹出窗口中选择是,则页面应刷新,否则应保持原样。
谢谢
您可以使用此 javascript 代码来检查页面刷新。
window.onbeforeunload = function(){
return "Do you want to refresh this page";
};
我这样做了并且成功了
window.onbeforeunload =
function(){
return "Refreshing page will result in loss of data, do you want to continue ?";
};
我想在用户单击 "refresh" 后显示一个确认弹出窗口 "Do you want to refresh this page"。如果用户在弹出窗口中选择是,则页面应刷新,否则应保持原样。
谢谢
您可以使用此 javascript 代码来检查页面刷新。
window.onbeforeunload = function(){
return "Do you want to refresh this page";
};
我这样做了并且成功了
window.onbeforeunload =
function(){
return "Refreshing page will result in loss of data, do you want to continue ?";
};