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
I managed to solve this problem inside the onbeforeunload event by checking event.target. This way you dont have to use outer variables or any extra bindings.
window.onbeforeunload = function (event) {
var activeElement = $(event.target.activeElement);
// console.log('onbeforeunload', activeElement);
var isMailto = activeElement && activeElement.is('[href^=mailto:]');
var isTel = activeElement && activeElement.is('[href^=tel:]');
if(!isMailto && !isTel) {
// logic when link is "normal"
}
};