You can do as following:
<script>
$(document).ready(function(){
$(':input').bind('change', function() { setConfirmUnload(true); });
$('#btnsavephoto').click(function() { setConfirmUnload(false); });
function setConfirmUnload(on)
{
window.onbeforeunload = on ? unloadMessage : null;
}
function unloadMessage()
{
return ('You have attempted to leave this page. ' +
'If you have made any changes to the fields without clicking the Save button, ' +
'your changes will be lost.');
}
});
</script>
I have written this line in above script:
$('#btnsavephoto').click(function() { setConfirmUnload(false); });
It means that warning message should not be displayed when click on upload photo submit button.
You can refer the following link for better understanding:
http://www.4guysfromrolla.com/webtech/100604-1.shtml[
^]