You can block the display of ads from sites in almost all types of browsers by installing the Adblock Plus add-on
If the computer is infected with viruses or any malicious programs that display ads in the browser, you can scan and clean using the utilities:
AdwCleaner
Malwarebytes Anti-Malware
Dr.Web CureIt!