Detecting Pop-Up Blockers

I was recently adding functionality on one of our sites that included having Shockwave and Flash movies pop open a a new browser window. I wanted the window to be a certain size, so I had the movies call a JavaScript function on the page to do the window creation. The problem was that many pop-up blockers would incorrectly kill this window, even though it was not an ad.
So I needed a way to get around the pop-up blockers, or at least inform the user that their pop-up blocker was interefering with the function that had requested. I found a lot of good information here:
Basically, the idea is to use to pop open the window. Then set a timeout to check for the window’s existance a second later. If the window doesn’t exist, then the window creation was blocked. I then use a window.alert to tell the user about it. They can then turn off their pop-up blocker, maybe just for this one site, and click on the button again to try to open the window.
The code for doing this can be found on that page, but only if you view the source. Not sure why it isn’t detailed more in the article.

Posted on September 16, 2004 at 10:04 am by Gary Rosenzweig · Permalink
In: General