Visitor Stats 2 logo Detect popup blocker.
 

How to check if the browser viewing this page is blocking popup windows

 

If you have a popup blocker enabled on your web browser, you will have just seen a Javascript alerting you to this.

*

 

This can be very useful on your own website, I use a popup window to view my shopping cart, but if a popup blocker is enabled on a users browser, then my potential customers have a very difficult time ordering on my website.


So, I either use the script above to read:

'You are using popup blocker software. This website needs to open a window to show you the shopping cart... please disable your popup blocker.'


Or, I check if they are using a popup blocker
, and then show them a direct link to click on which opens a window. This is more useful, as most popup blockers only block non-user activated poups, i.e. popups that happen without the user clicking a link. Also, it makes for a smoother experience as users don't have to turn their poup blocker on and off again just for your site (you will probably lose them, I wouldn't bother doing this for most websites).

'You are using popup blocker software. Please click here to your the shopping cart"

 

The Popup Code

 

You will need to copy and paste 2 bits of code.

Copy and paste this into your page before the </head> tag:

 

Now, copy and paste this anywhere in the rest of your page:

 

Done!

You can download this test page, test popup blocker.htm to see the script works on your website
(you will need to uncompress it from a ZIP file first)

 

Advanced use of the popup blocker detector

 

Here's a bit of code to give your users different options depending on whether or not they have a popup blocker enabled.

Now, copy and paste this anywhere in the rest of your page:

 

 

I hope you enjoyed this article / tutorial, I have many more on a wide range of website and internet topics.

Yari McGauley
Creator of Visitor Stats 2 - Topnotch website visitor tracking

 
Buy Visitor Stats
Version 2 for $79.95
Live Demo
Watch real visitors