The magazine of the Melbourne PC User Group

Blocking Ads and Pop-Ups
Dennis Parsons
 
 

Dennis Parsons explains how to avoid those annoying pop-ups and advertisements that interrupt your browsing

For many Internet users advertising inserted into Web pages and appearing as pop-up windows has become increasingly annoying. Not only do they cause distraction by covering the pages you're trying to read, requiring closing, they also slow the speed of pages downloading and consume bandwidth.

Fortunately there are a number of simple and quite effective ways to reduce these intrusions on your browsing experience, often eliminating them almost entirely. Like all solutions they aren't perfect and can have unintended side effects, but if ads and pop-ups bother you, then the occasional blocking of desired sites, graphics or pop-ups is probably a small price to pay. Best of all the solutions described here are free. There are non-free solutions available of course, and many other products such as firewall software may be configured to block ads and pop-ups.

My aim is to suggest simple and readily available solutions that are platform independent where possible. This is not a software review or comparison - where a particular piece of software is mentioned that's because it's simple and does the job. It may not be the best available and is almost certainly not the only one, so explore Tucows (tucows.melbpc.org.au) and use Google http://www.google.com.

Blocking Pop-ups

The blocking of pop-up (and pop-under) ads will have the biggest and most immediate visible effect. It is also the simplest to achieve as it is based on specific browser functionality and that makes it easy to control.

You may already be using the tool necessary to block pop-ups - your browser. If you use a recent version of a browser such as Mozilla http://www.mozilla.org, Opera http://www.opera.com or Netscape http://www.netscape.com then it already has the capability required.
 
Internet Explorer (IE) doesn't yet have this capability, although it is proposed in some form for inclusion in a service pack later this year. Until then a third party solution is required.

12Ghosts Popup-Killer http://www.12ghosts.com is a stand-alone application that blocks pop-ups for IE. It sits on the task bar.

Crazy Browser http://www.crazybrowser.com is basically a "skin" for IE in that it uses the underlying browser engine but provides its own interface. It also adds some enhanced functionality, including pop-up blocking.

Another effective choice for IE users is the Google Toolbar http://toolbar.google.com. It can report search information back to Google, so if that worries you make sure to configure it not to do so.
 


Figure 1. Google Toolbar

There will be times that wanted pop-ups are blocked, for example from some Internet banking sites or Melb PC's pop-up timer. Whether this happens or not depends on your blocker and can mostly be overcome by allowing pop-ups from the particular site or at worst temporarily disabling blocking.
 
Blocking Inline Ads

This is technically more difficult to achieve than blocking pop-ups because inline ads are often just images downloaded along with other images in a Web page. Fortunately they are often sourced from particular servers and tend to be of particular dimensions making it possible to form a strategy based around these and other characteristics.
Your browser may be able to block images from particular sites, which is useful if you regularly visit a page with advertising, such as Webmail, but as the blocking is for particular sites it is of limited general use.

Using The Hosts File

The most basic way to block ads is to add entries to your system's hosts file. The hosts file is the first place your computer looks to resolve domain names, that is, convert a human readable domain name into its Network readable IP address. For instance http://www.melbpc.org.au resolves to 203.12.152.19.
 

Usually this file has only a default reference to your own computer and all requests are handled by domain name servers (DNS) provided online. If, however, you enter IP address/domain name pairs these will take precedence. For normal Internet use this is totally impractical given the sheer number of domains out there and the difficulty in keeping it up to date. One specialist case where this is useful is for blocking advertising servers (or any other unwanted domain for that matter). You simply create an entry pairing a domain you wish to block with the internal IP address for your own system. Simply put, when your browser tries to download an ad from the blocked site it gets referred to your own system which can't provide the requested information, the site is unreachable and no ads appear.  
127.0.0.1 localhost
127.0.0.1 doubleclick.net
127.0.0.1 au.doubleclick.net
Location of the hosts file:
Windows 95/98/Me c:\windows\hosts
Windows NT/2000/XP Pro c:\winnt\system32\drivers\etc\hosts
Windows XP Home c:\windows\system32\drivers\etc\hosts
Linux /etc/hosts
 

Figure 2. An example hosts file.


It's not difficult to add entries as you discover ad sites you'd like to block, but it can rapidly get out of hand when done manually. Fortunately there are sites that have ready made hosts files for download. Search using your favourite search engine for "hosts file". Keep a backup copy of any additions you make, as the file can be automatically over-written at times.

Again there are downsides. Only whole domains and not directories, are blocked and you can't use wildcards. For instance you can block only doubleclick.net and not doubleclick.com/ads, which means you could be blocking more than you want. It also means you can't block ads served by the site you're visiting. Not using wildcards mean you must specify every domain name. For instance you can't use *.doubleclick.net to block both au.doubleclick.net and uk.doubleclick.net.

Despite these problems it can be a powerful if blunt tool, particularly if you download a precompiled list and augment it with your own entries. A nice side effect is it can increase the speed at which a page loads, as ads aren't being fetched - the requests aren't even making it outside your computer.
 



Figure 3. Unblocked.



Figure 4. Blocking of banner using the hosts file.



Figure 5. Full blocking using Privoxy.

Privoxy

Privoxy http://www.privoxy.org acts as a proxy server on your system, placing itself between your browser and the Internet. Any request your browser makes to download from the Internet is filtered by Privoxy which may allow the request, outright block it or block it but give you the opportunity to click and allow the request.

Privoxy is quite sophisticated, highly configurable and uses a number of different techniques. It can block based on domain (similar to the hosts file), image dimension (ad graphics often come in certain sizes) and image types (Flash graphics for instance). As with all blocking efforts there can be "collateral damage", for instance blocking images that unfortunately happen to be of just the wrong dimensions.

Troubleshooting

It's important to remember when browsing that you have these blocking tools in place. Their intended function is to block after all, so consider that when you're experiencing difficulty accessing a Web page or a link. Try reloading the page or link. Look at where the link is leading.
 
Is the domain included in your hosts file? Is it a link to a pop-up? Privoxy will often explain what it has done or give a link to click on to override it. Clearing your browser's cache or temporary files is often useful when turning blocking on or off, as is restarting your browser.

Only when you've tried these things should you consider other causes for the problem such as a page or site being down or no longer available, an ISP problem or a software problem.

Conclusion

I routinely use all three techniques (pop-up blocking, hosts file and Privoxy) together without conflict and I'm more than happy to tolerate the occasional unintended blocking that occurs. Pop-up blocking will probably have the largest impact on what you see, so start there and progress to ad blocking if desired.
A pop-up blocker test can be found at http://www.kephyr.com.

About the Author
Dennis Parsons has been a Melb PC member since 1996 and runs Linux as his OS of choice. He detests viruses, malware and spam and does what he can to help others avoid them. Avoids using a cricket bat as a teaching aid wherever possible.


Reprinted from the April 2004 issue of PC Update, the magazine of Melbourne PC User Group, Australia

[ About Melbourne PC User Group ]