0

Hey im working on a chatapp and i want to run an function before the window is being closed or refreshed i have found the following:

ready() {
   window.addEventListener('beforeunload', this.leaving());
}

But that doesnt not run the function can anyone help me?

simp you
  • 32
  • 12
  • 2
    you probably want to do `window.addEventListener('beforeunload', this.leaving);`, without the parenthesis, you want to pass the function without calling it – arieljuod Dec 24 '21 at 13:26

0 Answers0