jquery or javascript code before close or refresh a page

Hi,

I need a code that when a user refresh a page or close the page, then appears an alert that says "goodbye",

i don't want a confirmation message like onbeforeunload, i need to work in all browsers, any idea?

i always see onbeforeunload but i don't want the confirmation message, also i need to run other code before the "goodbye" alert, thanks
LVL 1
joyacv2Asked:
Who is Participating?
 
skijCommented:
You could use jQuery like this:
$(window).unload(function(){
  // put your code here...
  alert('goodbye');
});

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.