Possibly related to How to open mailto link in Chrome with Window.open without creating a new tab?
Hi all. I have a form page where i\'ve put a window.onbeforeunload co
Some other solution with pure JS and using the focused element:
window.addEventListener("beforeunload", () => { const isMailTo = document.activeElement.protocol === "mailto:"; if (!isMailTo) { // do your stuff } });