window.onbeforeunload
If i'm using a script like this for a comment section:
<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 = '';">
here's the whole form if it will make it any clearer...
HTML Code:
<script>
window.onbeforeunload = function() {
return 'Are you sure you want to navigate away from this page?';
};
</script>
<div class='module_header'> New Comment | <a class='f' href='<?php echo matry::here_to('lookup'); ?>'> Cancel</a> </div>
<form action='<?php echo matry::here(); ?>' id="rita" method='post' onchange="changes=true" onsubmit="var arr = new Array('NOTE1'); return mandatory(this, arr);" >
<table class='edit'>
<tr> <td> Note1 <?php tbox('NOTE1', 60, 4, 250); ?> </td> </tr>
<tr> <td> Note2 <?php tbox('NOTE2', 60, 4, 250); ?> </td> </tr> <tr> <td /> </tr>
<tr> <td> Note3 <?php tbox('NDATA', 60, 6, 6000); ?> </td> </tr>
<tr> <td> <?php echo lookup_link('Category', 'category', 'CATEGORY=Category&CATNAME=Description'); ?> <?php inp('CATEGORY',2); ?>
<input type='button' value='Clear' onClick="setval('CATEGORY',''); document.getElementById('CATNAME').innerHTML = '';" >
<span id='CATNAME'> </span> </td> </tr>
<tr> <td> <?php echo button::save('Add Comment'); ?> </td> </tr>
</table>
</form>