I want to write Jquery code in master file, so that if there if user changes page and there is any unsaved changes user should get alert. I got one answer from this: link
However in most solution I will have to write code on all pages. I want it to write only at one place so that everybody dont have to worry to write it in their modules. My code is like:
<script type="text/javascript">
var isChange;
$(document).ready(function () {
$("input[type='text']").change(function () {
isChange = true;
})
});
$(window).unload(function () {
if (isChange) {
alert('Handler for .unload() called.');
}
});
</script>
但每次我在文本框中进行更改.change()事件未触发.
代码中可能有什么错误?
编辑: 我将.change()更改为.click,它就会触发.我使用的是jQuery 1.4.1..是因为jQuery版本导致change()不起作用吗?