我想展示" onbeforeunload
提醒"选项卡关闭但填写表单后我关闭选项卡" onbeforeunload
alert"没有出现。
如何更改代码以及#34; onbeforeunload
警告"表格填写时可以显示?
我使用的代码是:
window.onbeforeunload = confirmExit;
function confirmExit() {
return "You are about to exit the system before freezing your declaration! If you leave now and never return to freeze your declaration; then they will not go into effect and you may lose tax deduction, Are you sure you want to leave now?";
}
$(function() {
$("a").click(function() {
window.onbeforeunload = null;
});
$("input").click(function() {
window.onbeforeunload = null;
});
});
答案 0 :(得分:1)
如何更改代码"
unbeforeunload
alert"表格填写时可以显示吗?
您实际上是通过填写表单来点击<input />
吗?因此,点击<input />
后,unbeforeunload
将设置为null
(删除提醒),代码如下:
$("input").click(function() {
window.onbeforeunload = null;
});
请删除该代码,然后就可以了。 :)
或者您可以定位提交按钮,更具体地说:
$("input").click(function() {
window.onbeforeunload = null;
});
$("input[type='submit']").click(function() {
window.onbeforeunload = confirmExit;
});