How can you stop sites from sending unwanted or 'enforced' downloads in Safari? I'm not the only one who has been plagued lately with seemingly well-meaning sites suddenly warning me that some piece of software on my Mac is out-of-date and that I need to update 'whatever' (often Flash).  Then, my browser just goes ahead and accepts their download (probably malware) onto my computer and I can't stop it.  How can we stop Safari from downloading files without asking first?  It seems that these infected sites 'push' the downloads on you, and Safari does nothing to stop it.  BTW I'm using Sierra (10.12.6) and Safari 12.1.2.  I hear that this happens with other browsers as well.  Open "Safe Files" after downloading checkbox is not checked. Any ideas?
The real solution is upgrading to Safari 13, but there does exist a solution on Safari 12 and earlier.
Open Safari Preferences, choose the General tab, and for the download location choose ‘ask for each download’.
With this option select, Safari will prompt for a file name and a location to save the file, which you can cancel so the download doesn't take place.