Last active
December 16, 2015 03:48
Detect if a popup is blocked in major browsers
This file contains 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
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