我想创建一个onbeforeunload
“你已经对该页面进行了编辑。请继续阅读本页,将此页面保留为”jQuery插件。
该插件需要:
$(".editableFieldContainer").beforeUnload()
not(:hidden)
input / textarea / choices。像这样(但不完全是,它缺少一些功能):
(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.";}
};
}());
是否已经有一个像样的插件?