Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.unload not working in jquery

Here I have an anchor tag in my html page which will go to Google when I click. I have a jQuery function which needs to be fired when the page leaves.

$(window).unload(function(){
    alert('fffffffff');
 });

I found this works fine in a video tutorial. But it's not working for me. Using firefox. help

like image 629
Shameer Avatar asked Dec 25 '22 20:12

Shameer


1 Answers

Its working fine, you just need to remove the alert, as some browsers don't allow alert on unload event.

$(window).unload(function(){
   console.log("hello");
});

try this http://jsfiddle.net/vyMdF/

Just run it again and you can check the console.

You can refer over here $(window).unload is not firing

like image 71
Ashis Kumar Avatar answered Dec 28 '22 09:12

Ashis Kumar