Skip to content

Instantly share code, notes, and snippets.

@benkitzelman
Last active December 16, 2015 03:48
Show Gist options
  • Save benkitzelman/5372051 to your computer and use it in GitHub Desktop.
Save benkitzelman/5372051 to your computer and use it in GitHub Desktop.
Detect if a popup is blocked in major browsers
var isPopupBlocked = function() {
var isBlocked,
popup = window.open('about:blank', 'popup_test','width=5, height=5, left=0, top=0');
// pop under
if(popup) popup.blur();
window.focus();
isBlocked = !popup || typeof popup == 'undefined' || typeof popup.closed=='undefined' || popup.closed || popup.innerHeight == 0;
if(popup) popup.close();
return isBlocked;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment