I assign the element id "btn_submit" to write_ok button.
I wanted the following:
if I press write_ok button,
do write,
else (if I do not press write_ok button)
do alert message before page exit.
I don't know how can i find out which button was pressed.
I found this, but I cannot get it to work: jQuery: how to get which button was clicked upon form submission?
<script type="text/javascript">
$(window).bind('beforeunload', function(){
if ( #btn_submit was not pressed )
return 'If you exit the page, you may lose your changes';
});
</script>