Google Chrome Popup Detection that actually works !

Hi,
When i started looking out for javascript code that can detect Chrome’s (17.0) popup blocker, I tried lots of snippets. But most of them dint really work. So once i got it working, I thought it would be good to share with you so that you can make use of the same in your projects. The following is the code snippet::

What this script does is,
1. Tries to open a popup window and store the window handler in pop variable.
2. Declare an anonymous function  with setTimeout set to 1000 milli sec, i.e.  1 sec.
3. So apparently once the 1 sec is complete and the anonymous function gets executed,
3.1 We check if the popup has been loaded, we can see that the ‘pop.innerWidth’  is being used to detect the chrome’s popup mechanism as the popup window’s innerWidth property would have been set to 0 if the popup blocker is enabled.
4. Once all is done we close the popup we had opened.
Send me your comments/suggestions to further optimize the solution.
 
P.S : as per updates from Anders the script was not working on Chrome 19, now with the inputs from Anders i have modified the script to check for :

This compares the height and width values to the exact height and width values I set on window.open() method i.e.  150X150 , this enables us to correctly find if the popup is enabled or not. I have checked it on Chrome 21.
Please check out the below mentioned updated code and let me know if you face any issues.
Cheers.
Anand
 

 

8 thoughts on “Google Chrome Popup Detection that actually works !

  1. This doesn’t work anymore for me (Chrome version 19). I resorted to check if the opened windows size (pop.document.documentElement.clientHeight and pop.document.documentElement.clientWidth) was the same as the size I requested in window.open().

  2. hye, thank for the code..however it works only in chrome..not in firefox..in firefox, i only get ‘Popup Must Be Enabled’ even when i already disable the blocker..
    please advice..thank you!

      1. I eliminated the part of the script that checks for height and now it works on the latest version of Firefox too.

Leave a Reply