newbie123
newbie123

Reputation: 27

javascript onbeforeunload then onunload event

Trying to use onbeforeunload then onunload but the onunload script does not seem to work.

  window.onbeforeunload = confirmExit();
  window.onunload = unloading();                  
  function unloading() {
      alert("testicles");
      confirm("try");
  }
  function confirmExit(evt) {
      return 'test1';
  }

Upvotes: 1

Views: 121

Answers (1)

Sanshila
Sanshila

Reputation: 158

It seems you missed "()" while calling unloading function. Try this:

window.onbeforeunload = confirmExit();
window.onunload = unloading();

Upvotes: 1

Related Questions