Javascript窗口onbeforeunload事件问题 [英] Javascript Window onbeforeunload event issue
问题描述
你好朋友,
在我当前的项目之一中,我正在使用window.onbeforeunload事件检查一些值.如果选择停留在此页面上",则需要在此操作过程中将值(如果有任何值更改)重置为原始值,但我没有得到如何执行此操作.有什么方法可以找到离开此页面"和停留在此页面"对话框的返回值吗?
例如:有一个下拉列表,其值为A,B,C.它的初始值为A,在工作期间,我将其更改为B并关闭了该窗口,但未保存该值.如果我选择停留在此页面上,那么我想将下拉列表的值重置为A.这怎么可能?
任何帮助将不胜感激.
亲切的问候,
Jagjot
Hello Friends,
In one of my current projects, I am using window.onbeforeunload event to check some values. I need to reset the values (if any value changed) to original values during this operation if I select "Stay on this page", but I am not getting how to do this. Is there any way to find a return value of "Leave this page" and "Stay on this page" dialog box?
For example: There is a dropdown which is having values A,B,C. Its initial value is A, during the work, I changed it to B and closed the window without saving that value. If I select stay on this page, then I want to reset the value of dropdown to A. How is this possible?
Any help will be appreciated.
Kind Regards,
Jagjot
推荐答案
使用confirm
,您可以轻松设置自定义文本:
http://www.pageresource.com/jscript/jconfirm.htm [ http://theinfiniteloopblog.com/tag/change-javascript-confirm-button-text/ [ ^ ]
祝您好运!
Withconfirm
you can simply set your custom text:
http://www.pageresource.com/jscript/jconfirm.htm[^]
Or use jQuery:
http://theinfiniteloopblog.com/tag/change-javascript-confirm-button-text/[^]
Good luck!
在Google上停留2秒钟 [ ^ ]
这篇关于Javascript窗口onbeforeunload事件问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!