I know that I can bind handler to onbeforeunload
event and execute something before full page unload. But is there a way to do this on razor view of _Layout?
CodePudding user response:
Yes,it could,If you add the js codes in _layout,when you leave the page,it would work I added the codes in my layout:
<script type="text/javascript">
window.onbeforeunload = function (){
return("");
}
</script>
when I leave the page, a dialogue pop out
You could share your codes if you have problems when you add the function of onbeforeunload