Skip to content

Instantly share code, notes, and snippets.

@pid
Created June 28, 2013 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pid/5886387 to your computer and use it in GitHub Desktop.
Save pid/5886387 to your computer and use it in GitHub Desktop.
test popup blocker
var newWindow = open("http://fiddle.jshell.net/_display/", "test"),
looplimit = 3,
x=0;
function loopy() {
if (newWindow.innerHeight > 1) {
console.log(" opened2 ");
} else {
x++;
if ( x > looplimit) {
console.log(" blocked ");
} else {
setTimeout(loopy, 2000);
}
}
}
if (!newWindow) {
console.log(" blocked ");
} else if (newWindow && newWindow.innerHeight < 1) {
// Chrome blocked the popup lets check in a little bit if then open the window.
newWindow.onload = loopy;
} else {
console.log(" opened1 ");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment