Click here to Skip to main content
15,118,017 members
Articles / Web Development / HTML
Posted 10 Jan 2005


25 bookmarked

OxFF - Another way to block popups

Rate me:
Please Sign up or sign in to vote.
4.73/5 (16 votes)
10 Jan 2005CPOL5 min read
Popup blocker with source code.

Sample Image


The annoying popup ads have literally exploded on our beloved Internet. Nonetheless, the pop blockers, killers (or however they may be called) have also been "exploding". Most of them come to us against some costs, others are for free. Some of them take too much control of our surfing, not letting legitimate windows pop up sometimes. Others are too complex, providing us with a lot of option lists and settings which may not match the different contexts of surfing.

Anyway, software people are doing a real good work on that, and they are not to blame if not a 100% of the users are happy. This will never happen! Should you need a popup killer review, you can find useful information here. My personal opinion is that the firewall software suit accompanying XP does a wonderful job in this area of interest.

Excellent coding approaches along with their accompanying comments are provided within CP community. Most relevant of them (in alphabetical order) are provided by:

OxFF comes with a new approach which combines the versatility of the IWebBrowser2 interface with the background support of the DirectX technology. People working within home or office networks may find this tool useful. Pertinent, constructive feedback will be highly appreciated. A debate might prove to be of greater use than this tool itself.

Let Year 2005 help you being in good shape, full of success, and free of popups!

Using OxFF

OxFF works with the following assumption: A legitimate popup window is a new window opened as a result of a mouse click on an HTML element within a browser page.

OxFF allows only one browser instance work at a time, stopping any other attempt to open a new one. In case of a legitimate pop-up, it opens the new window, but kills the previous one, memorizing its "navigated" URL for "Back" functionality. The number of stopped popups is displayed at the bottom of OxFF.

Image 2

DirectX 8 or higher must be installed on your computer. Download DirectX 9 from the Microsoft site.

The following commands are available:

  • Double click on the trash bin

    Disable / enable OxFF.

  • Left click on the trash bin

    Empty the bin and reset the popup counter.

  • Right click on the trash bin

    Navigate within the legitimate popup window to the URL used by the window killed when this popup was allowed to show up ("back" functionality).

  • ESC, when OxFF's window is active (i.e. selected)

    Close OxFF.

Note: A legitimate popup window has no navigation history, as it is new. Therefore, its "Back" button is disabled. That is why the "back" functionality is provided by OxFF.

How it works

Logically, OxFF is structured in two modules:

  • One module keeps track of the web browser instances registered on your computer
  • Another module polls the mouse state (position and buttons)

More information on keeping track of the registered browser instances can be found in my article concerning the "Style Inspector".

OxFF allows only one browser instance. Any further instance is forced to quit by the instance tracking module. Please notice that OxFF will treat even a new browser instance created by you (when starting another Internet Explorer session) as a non-legitimate popup. Remember, you can disable OxFF at any time. When re-enabling OxFF, any new popup will be intercepted and only the very first opened browser instance will be kept alive.

The question is: what happens when a legitimate new window must show up? This is the case, for example, of the mail server system of the company I am working for. After entering my e-mail box, a new window opens when I click the "Inbox" item. And this is definitely a legitimate pop-up!

The mouse state polling module, based on the DirectX technology, is responsible for treating these kind of situations. When polling (in the background), the module gets two window handlers:

  • A handler to the foreground window (i.e., of the window the user is currently working with), by calling
  • A handler to the main window of the browser, by using a pointer to the browser instance (let it be IWebBrowser2* lpBrowser) and by calling:

In case those two handlers are the same, any left mouse click is related to working with the browser window (and not with other applications that may be running at the same time). OxFF "opens" a trust time-window, in which a popup becomes legitimate, and starts two timeout counters (one to turn off a pre-legitimation flag and a second one to "close" the trust time-window) that are useful when the user clicks within the browser window, but the result of the click is normally not a new window. The "trust" time, during which a popup is allowed to show up, is 1 second. I expect discussions here (which are welcome, of course). When a legitimate popup shows up, OxFF memorizes the URL used by the browser instance up to that point, forces that instance to quit, and makes the new browser instance the working one (so still only one in the list). Going back to the web page that generated the process of legitimating the popup window is possible now because of the memorized URL. By right clicking the popup trash bin, the user instructs OxFF to navigate to that URL within the present browser instance.


Created: January, 2005.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Mircea Puiu
Software Developer (Senior)
Europe Europe
More than 22 years of software development experience.
SCRUM Master nowadays

Comments and Discussions

GeneralMain Problem Pin
Other Anonymous20-Jan-05 0:30
sussOther Anonymous20-Jan-05 0:30 
GeneralRe: Main Problem Pin
Mircea Puiu20-Jan-05 9:36
MemberMircea Puiu20-Jan-05 9:36 
GeneralInteresting approach Pin
The Little Lloyd10-Jan-05 8:03
MemberThe Little Lloyd10-Jan-05 8:03 
GeneralDon't waste your time... Pin
Anonymous10-Jan-05 5:41
MemberAnonymous10-Jan-05 5:41 
GeneralRe: Don't waste your time... Pin
John M. Drescher10-Jan-05 5:59
MemberJohn M. Drescher10-Jan-05 5:59 
GeneralWhy? : Don't waste your time... Pin
go_gilly10-Jan-05 6:12
Membergo_gilly10-Jan-05 6:12 
GeneralError: Division by Anonymous! Pin
Mircea Puiu10-Jan-05 6:06
MemberMircea Puiu10-Jan-05 6:06 
GeneralCOOOL :rolleyes: Division by Anonymous! Pin
The Little Lloyd10-Jan-05 8:07
MemberThe Little Lloyd10-Jan-05 8:07 
GeneralRe: Don't waste your time... Pin
Nicholas Cardi10-Jan-05 6:33
MemberNicholas Cardi10-Jan-05 6:33 
GeneralRe: Don't waste your time... Pin
storein18-Feb-06 18:01
Memberstorein18-Feb-06 18:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.