I am trying to open a link in new tab evoked onblur, however as popup blocker triggers a block I am now trying to sync a dialog to confirm so the the new tab isn't blocked when opening. I am trying to use the below code but I can't seem to work it properly. I have also tried another script but keep getting hit with the popup blocker using confirmit On blur confirm it
The code I would want to use is below. When I click the link alone the dialog seems to be working perfectly and opens new tab, how do I implement so on blur the same dialog is triggered and when user clicks to confirm a new tab is opened without popup blocker getting evoked:
<a href="www.google.com" class="confirmation" target="_blank">Link</a>
<script>
$(window).blur(function() {
var elems = document.getElementsByClassName('confirmation');
var confirmIt = function (e) {
if (!confirm('Are you sure?')) e.preventDefault();
};
for (var i = 0, l = elems.length; i < l; i++) {
elems[i].addEventListener('click', confirmIt, false);
}
})
</script>