David Karlsson
David Karlsson

Reputation: 9696

Running a method on browser close tab or browser exit

Is there an action handler I can use in Javascript+Angular+JQuery that makes it possible to schedule a method to be executed just before a tab is closed in the web browser?

By close I mean quitting the browser or closing the tab or crashing or anything...

Upvotes: 3

Views: 2265

Answers (1)

Kevin Stone
Kevin Stone

Reputation: 8981

Yeah, you just bind the the beforeunload on the window object.

angular.element($window).bind("beforeunload", exitHandler)

Upvotes: 4

Related Questions