简体   繁体   中英

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?

<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. ; ]

You may want to check out this post: Trigger onbeforeunload if form is not submitted

You can set onbeforeunload to null when your form is submitted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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