简体   繁体   English

使用onbeforeunload:

[英]Using onbeforeunload:

<script>window.onbeforeunload = function() { return "Sure?"; }</script>

I don't want it to ask if they select the "add comment" button... it's basically a reminder for if they begin to navigate away without adding the comment.. any help would be greatly appreciated. 我不想问他们是否选择了“添加评论”按钮...这基本上是在提醒他们是否开始导航而不添加评论。任何帮助将不胜感激。 Thanks. 谢谢。

Is it causing conflict because i already have an onClick event? 是否因为我已经有onClick事件而引起冲突?

<input type='button' value='Clear' onClick="setval('CATEGORY',''); 
document.getElementById('CATNAME').innerHTML = '';">

Thanks in advance, I'm new to stackoverflow so lay it on me if necessary. 在此先感谢您,我是stackoverflow的新手,因此如有必要,请依靠我。 ; ; ] ]

You may want to check out this post: Trigger onbeforeunload if form is not submitted 您可能想查看此帖子: 如果未提交表单,则触发onb​​eforeunload

You can set onbeforeunload to null when your form is submitted. 您可以在提交表单时将onbeforeunload设置为null。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM