document.onkeydown = keydown;
function keydown(evt)
{
if (!evt)
evt = event;
if (evt.altKey && evt.keyCode==115)
{
alert("ALT+F4");
}
}
Instead you can also try below script:
<script>
var userIsEditingSomething;
oldOnBeforeUnload = window.onbeforeunload;
window.onbeforeunload = function ()
{
if ('function' === typeof oldOnBeforeUnload)
{
var message = oldOnBeforeUnload();
if ('undefined' !== typeof message)
{
if (confirm('string' === typeof message ? message : 'Are you sure you want to leave this page?'))
{
return;
}
}
}
if (userIsEditingSomething)
{
return 'Are you sure you want to exit?';
}
}; </script>
I got this script from :
http://stackoverflow.com/questions/4427714/confirm-dialog-when-i-close-the-browser[
^]