You can block…

… a popup with NoScript or similar.
… an ad with AdBlock+ or similar.
… Flash, if you disable its plugin.