Search code examples
javascriptjqueryonbeforeunload

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


Solution

  • 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.