Most of those types of pop-ups are just trying to get you to click on something or phone a number, and are using scare tactics to make that attempt.
To stay safe(r):
Never click on something that says 'click here to view this web page correctly'. If you need Flash or whatever, go directly to the software manufacturer's website and download from there.
Never click on anything that says 'Your computer has been infected with malware/viruses/etc.' even if it seems to be a message box from protection software you installed yourself. Open your software directly and check from there.
Never click on anything that says 'Your driver is out of date, update it here'. Update your drivers through your OS's update facility or directly from the manufacturer's website for your hardware.
Be very careful where you download from, especially for free.
Never download something for free if it's something you'd normally have to pay for, unless it's being offered by the individual or company who own the rights to it (as a special/free trial/etc.)- regardless of the legality and morality, there's also a good chance of picking up an infection with it.
Have antivirus and antimalware software, keep them up to date, and run regular scans. One program that does both jobs, or two that do one each. Not more than one for each job, it's common for them to start fighting each other. If you're otherwise being sensible then Windows' own software should be fine, but if you want an alternative then Avast and AVG are generally good- just check if they play well with any computer games you might want to indulge in.
Don't use Windows? Not an option for many, but the spyware/virus/malware writers follow the crowds. The less common your OS, the less chance you'll have of picking up a nasty. Novell Netware was a good one to confuse scammers with (as was "Good morning, computer technical support department, can I help you?").
My older brother is well clued-up and if he answers the phone to a scammer he plays them along for as long as he can
I think it's common entertainment among tech support folks to string along the scammers and waste their phonebill. A friend claims to have kept them on the line for 35 minutes before the scammer got annoyed and rang off. Extra marks if you manage to wind them up enough to swear at you, or if you manage to get their log-in details off them. To get rid of them more quickly try "One moment please, I'm just tracking your IP and MAC addresses, please stay on the line." Or just pretend to never have heard of computers and assume all mentions of windows refer to those things with glass in that let you look through walls (little old lady voice helps to add authenticity to that one).