You need to take a serious look at the sites you're cruising and you need to be running a good ad blocker, and be sure to keep your system updated.
Assuming you haven't downloaded a program containing a trojan most likely you're getting those from either a banner ad, a pop up, or a particular web site either by being re-directed to it or from a CSS attack. (Cross Site Scripting)
The bad thing about pop-ups is they might be something other than annoying. They can be set up so that when you think you're clicking it away you're actually triggering a download..... when that happens the DL can be anything from a browser hijacker giving you more pop-ups or any type of malware there is. Anytime you're getting a lot of pop-ups at once you should be very suspicious. Either you're already infected or you're being set up for a buffer overrun attack.
Best thing is to reboot your system and do a scan. Then get back online on a different site, preferably a site you can trust that you've visited before.... then if you're still getting odd messages or pop-ups you're definitely infected. You'll need to research what to do or take it to a pro, or maybe your teenage nephew, LOL
If this happens to you on a regular basis you might want to look at running a live OS for the kind of browsing you're doing, or for when you do sensitive things like banking.
Avoid public WIFI and if you can't then get a VPN with end to end encryption.