Opposite of window.onload ?

2 replies
Hi Im new on programming javascript and have this question.

If window.onload will trigger a function when you open the page.
My question is whats the code if you want a function to execute once the user leave the page or close it.

I have seen this on sales pages but not sure the exact keyword to search on google regarding this matter.

Thanks
#opposite #windowonload
  • Profile picture of the author GMF1
    I found something on Stackoverflow that might help you

    Has something to do with the onbeforeunload event.

    Code:
    stackoverflow.com/questions/147636/best-way-to-detect-when-user-leaves-a-web-page
    {{ DiscussionBoard.errors[6600999].message }}
  • Profile picture of the author kojakeugenio
    Thanks bud thats it!
    Signature
    Best Blog Commenting Software
    Youlikehits ROBOT - Earn 15k+ points daily for FREE!
    Contact me for your Custom Bot Needs - CLICK HERE!
    {{ DiscussionBoard.errors[6601037].message }}

Trending Topics