0

I want to execute some code when user close their browser. I found some piece of code and try it, but it is not working. I notice that it is working when I am clicking on Run link at jsfiddle. I dont know why.

$(function(){
$(window).on('beforeunload', function(){
    alert(0)    
})  
})

Fiddle

Jitender
  • 7,593
  • 30
  • 104
  • 210

1 Answers1

0

when the beforeunload event is triggered generates an default alert

$(function(){
$(window).on('beforeunload', function(){   
 return 'message';
 });  
});

you can override the message like the above code sample

Anushka D
  • 1
  • 2