try running a cleaner on your phone.
SD Maid's system cleaner will look for ad files and remove them : https://forums.androidcentral.com/e...ps/details?id=eu.thedarken.sdm&token=ue0Ax7Dp
then there is also the popular clean master : https://forums.androidcentral.com/e...ails?id=com.cleanmaster.mguard&token=Q5B0k9At
think of what you might have downloaded recently before this problem began.
it might be an app you've given way too many permissions or junk you've downloaded from outside the play store... via torrent for instance.
in any case try removing these latest downloads until the problem is gone. SD Maid can tell you which apps are currently running (in memory). that could give you a hint.
in the worst case scenario you'll have to reset the phone to get rid of it so you might as well think hard what you've been letting into your phone lately. and did you run a AV check?
another thing that comes to mind would be to delete your browser cache, history, and junk files. it might not be that but no harm in cleaning it up.
There are dodgy apps on the Play Store. An app being on the Play Store does not guarantee safety. Look at the reviews and number of downloads. If either are low don't bother. It has nothing to do with your browser being open. You've downloaded something that contains this on to your phone. You either need to run something like "AVG Anti-virus free" or uninstall apps you don't completely trust until it is removed. A factory reset will remove it. But this is an extreme measure. If you uninstall the app causing it, the problem should be fixed.
Then you're going to have to start uninstalling your most recent apps until it goes. Or factory reset. Before that though another thing you could try is go to Settings>Security>Device Administrators. Are there any apps with permissions there that shouldn't? You could also go Settings>Apps> then choose the option to reset app preferences.
If they are ads and appear in your notifications you could also try AirPush from the Play Store. It detects apps that have push notifications and other apps that could be spying on you. As a last resort, as you mentioned, Factory Reset. Then add things back slowly beginning with the most trusted apps. It's a slow process but if your patient you can find it and avoid installing it again.
I've already liked JBeef's suggestion of checking reviews, even at the Play Store. This is usually a good tool for finding problems, because people will usually post if an app has done them wrong. Just because it's at the Play Store does not ensure it's a completely good and just app.