I use an addon called NoScript for Firefox. It automatically blocks scripts from every site until you allow them. It's a pain in the beginning because it prevents java scripts, flash players, certain images etc. on all sites - but eventually when you've allowed your favorite addresses it's nice.
In other words it prevents any form of advertisements, popups, keyloggers or redirection scripts and stuff like that - all in one addon. Frequently updated too so I highly recommend it, especially if you surf around much and on many different sites. You never have to fear clicking suspicious links and so.