Menu Close
    Hire us Request quote Reading list Switch to dark mode

    Detect browser tab refresh and browser tab close using javascript

    There is no function to differentiate between browser tab refresh and browser tab close but i found a way to differentiate between two.

    We have

    Function ‘onload’ – it is fired when we refresh browser tab.

    Function ‘unload’ – it is fired when we either refresh browser tab or close browser tab.

    Requirement

    We don’t have a single function in javascript which works only on browser tab close.

    How to achieve this ?

    Solution

    . . .

    Comments (4)

    Add Your Comment

  • Sagar Shinde
    This code will not work when we reload the page using URL or button present on browser menu bar.
  • Sarath P Sasidharan
    Thanks
    • Webkul Support
      Hi Sarath P, thanks for the appreciation 🙂
  • blacmoon
    Where to find that?
  • Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just received your message and our expert will get back to you shortly.
    Send Again
    Close