Last active
October 29, 2018 11:15
-
-
Save loopdream/65c842dd96450751dd3c to your computer and use it in GitHub Desktop.
Open link in new tab - checks for popup blocker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openInNewTab = function(url) { | |
var popupBlockerChecker = { | |
check: function(popup_window){ | |
var _scope = this; | |
if (popup_window) { | |
if(/chrome/.test(navigator.userAgent.toLowerCase())){ | |
setTimeout(function () { | |
_scope._is_popup_blocked(_scope, popup_window); | |
},200); | |
}else{ | |
popup_window.onload = function () { | |
_scope._is_popup_blocked(_scope, popup_window); | |
}; | |
} | |
}else{ | |
_scope._displayError(); | |
} | |
}, | |
_is_popup_blocked: function(scope, popup_window){ | |
if ((popup_window.innerHeight > 0)==false){ scope._displayError(); } | |
}, | |
_displayError: function(){ | |
alert("Popup Blocker is enabled! Please add this site to your exception list."); | |
} | |
}; | |
var popup = window.open(url, '_blank'); | |
popupBlockerChecker.check(popup); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment