jquery - Showing alert box on `beforeunload` event -


i want show alert box on beforeunload event. using following code that. problem this, not show alert box on event.

$(window).bind('beforeunload', function() {                 alert($(location).attr('hostname'));             }); 

how can problem resolved?

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

this have do.

basically can use without jquery

window.onbeforeunload=function(){ return location.hostname; }; 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -