代码如下:
window.onbeforeunload = function() {
if(is_form_changed()) {
return "您的 修改内容还没有 保存,您确定 离开吗?";
}
}
function is_form_changed() {
var t_save = jQuery("#t_save"); // 检测页面是否要 保存按钮
if(t_save.length>0) { // 检测到 保存按钮,继续 检测元素是否修改
var is_changed = false;
jQuery("#A4 input, #A4 textarea, #A4 select").each(function() {
var _v = jQuery(this).attr('_value');
if(typeof(_v) == 'undefined') _v = '';
if(_v != jQuery(this).val()) is_changed = true;
});
return is_changed;
}
return false;
}
jQuery(document).ready(function(){
jQuery("#A4 input, #A4 textarea, #A4 select").each(function() {
jQuery(this).attr('_value', jQuery(this).val());
});
});
window.onbeforeunload = function() {
if(is_form_changed()) {
return "您的 修改内容还没有 保存,您确定 离开吗?";
}
}
function is_form_changed() {
var t_save = jQuery("#t_save"); // 检测页面是否要 保存按钮
if(t_save.length>0) { // 检测到 保存按钮,继续 检测元素是否修改
var is_changed = false;
jQuery("#A4 input, #A4 textarea, #A4 select").each(function() {
var _v = jQuery(this).attr('_value');
if(typeof(_v) == 'undefined') _v = '';
if(_v != jQuery(this).val()) is_changed = true;
});
return is_changed;
}
return false;
}
jQuery(document).ready(function(){
jQuery("#A4 input, #A4 textarea, #A4 select").each(function() {
jQuery(this).attr('_value', jQuery(this).val());
});
});