i’m trying to close the browser window with the ESC key, but dont know why the self.close dos not work.
this is what i’m doing (i try use document in place of body but nothing change ):
$('body').keydown(function(e) {
if(e.keyCode == 27){
alert(e.keyCode); // alert work fine ( 27 )
self.close();
}
});
what i’m missing ?
edit:
doing this work fine:
$("#closeWindow").click(function(){
self.close();
});
thanks.
Since your alert is working, I assume the self.close() is failing for security reasons.
This code is a hack to get around this security measure: