我想要创建一个onbeforeunload“您已经对页面做了编辑。留在这个页面上,离开这个页面”jQuery插件。
插件需要:
$(".editableFieldContainer").beforeUnload()not(:hidden)输入/文本区域/选择的更改。- except if the page was submitted via form.
- except if the page/user wants to cancel the changes, e.g., a "Cancel" link/button was pressed.
类似这样的东西(但不完全是,它缺少了一些功能):
(function(){
var changed = false;
$.beforeUnloadCanceled = false;
$.fn.beforeUnload = function(){
$.beforeUnloadCanceled = true;
return $(this).delegate("input,select,textarea", "change", function(){
changed = true;
});
});
window.onbeforeunload = function(){
if(changed && !beforeUnloadCanceled){return "You have made edits to the page.";}
};
}());已经有一个不错的插件可以做到这一点了吗?
发布于 2010-10-26 17:51:28
这可能就是你要找的。
jquery.wtFormDirty-2.0.2.js
https://stackoverflow.com/questions/4025779
复制相似问题