Click here to Skip to main content
15,867,568 members
Articles / Web Development / HTML
Article

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 52.4K   1K   25   10
Popup blocker with source code.

Sample Image

Introduction

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
    GetForegroundWindow()->GetSafeHwnd()
  • 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:
    lpBrowser->get_HWND()

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.

History

Created: January, 2005.

License

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


Written By
Software Developer (Senior)
Europe Europe
More than 30 years of software development experience.
(also playing the SCRUM Master role depending on the project)

Comments and Discussions

 
GeneralMain Problem Pin
Other Anonymous19-Jan-05 23:30
sussOther Anonymous19-Jan-05 23:30 
GeneralRe: Main Problem Pin
Mircea Puiu20-Jan-05 8:36
Mircea Puiu20-Jan-05 8:36 
GeneralInteresting approach Pin
The Little Lloyd10-Jan-05 7:03
The Little Lloyd10-Jan-05 7:03 
GeneralDon't waste your time... Pin
Anonymous10-Jan-05 4:41
Anonymous10-Jan-05 4:41 
GeneralRe: Don't waste your time... Pin
John M. Drescher10-Jan-05 4:59
John M. Drescher10-Jan-05 4:59 
GeneralWhy? : Don't waste your time... Pin
go_gilly10-Jan-05 5:12
go_gilly10-Jan-05 5:12 
John, the man says at the beginning of his article that what's coming with XP (i.e. SP2) is a very good solution. I do not see why we shouldn't read the article ?!? This attidude seems to me a little bit ... strange Cry | :((
GeneralError: Division by Anonymous! Pin
Mircea Puiu10-Jan-05 5:06
Mircea Puiu10-Jan-05 5:06 
GeneralCOOOL :rolleyes: Division by Anonymous! Pin
The Little Lloyd10-Jan-05 7:07
The Little Lloyd10-Jan-05 7:07 
GeneralRe: Don't waste your time... Pin
Nicholas Cardi10-Jan-05 5:33
Nicholas Cardi10-Jan-05 5:33 
GeneralRe: Don't waste your time... Pin
storein18-Feb-06 17:01
storein18-Feb-06 17: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.