<script src="//code.jquery.com/jquery-1.8.2.js"></script>
<script src="//code.jquery.com/ui/1.8.4/jquery-ui.js"></script>
<script type="text/javascript">
$(function () {
$(window).on('beforeunload', function () {
// here paste you function();
return '';
});
});
</script>
I want to call code behind function Where return :-
// here paste you function();