I am using the following code.
window.addEventListener('beforeunload', (event) => {
event.returnValue = `Are you sure you want to leave?`;
});
How can I edit it so that it only fires when a user is closing the browser window and not clicking a link or form submit.
I would prefer to edit / add more javascript than have to add anything to my links - as the links change actively.