Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
My Modified Popup Blocker Checker/Handler Code (JS)
// Based on Stackoverflow answer here:
// My modified handler
MyGlobalScope.popupBlockerChecker = {
check: function(popup_window, urlAttemptingToOpen){
var _scope = this;
if (popup_window) {
setTimeout(function () {
_scope._is_popup_blocked(_scope, popup_window, urlAttemptingToOpen);
popup_window.onload = function () {
_scope._is_popup_blocked(_scope, popup_window, urlAttemptingToOpen);
_is_popup_blocked: function (scope, popup_window, urlAttemptingToOpen) {
if ((popup_window.innerHeight > 0) == false) { scope._displayError(urlAttemptingToOpen); }
_displayError: function (urlAttemptingToOpen) {
// NOTE external dependency here of toastr. But you can notify the user however you want.
toastr.error("Popup blocker is enabled! Please add this site to your exception list or turn off the blocker. " +
"<a target='_blank' style='color: blue;' href='" + urlAttemptingToOpen + "'>Click here</a> to open the window.");
// Then, anywhere in code, I invoke like this:
var urlToOpen = '/#/my_url_with_parameters';
var popup =, 'MyWindowName', {});
MyGlobalScope.popupBlockerChecker.check(popup, urlToOpen);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.