I am trying to use window.onbeforeunload in my project but I do not know how to use it.
window.onbeforeunload
I have tried in 2 ways:
1st way
<
create a file beforeunload.js that you put in the assets folder, containing
beforeunload.js
assets
window.beforeunload = function() { // Do your stuff }
In your angualr-cli.json, simply import the file :
angualr-cli.json
"scripts": [ "assets/beforeunload.js" ],