Iv never understood how just visiting a website can open you up to attack- does anyone know the answer?
When you go to a website it can have code within it that executes without you even seeing it do anything. Literally as the page loads, the code runs against your machine.
Not all websites are simple HTML/XHTML and CSS, some if not most these days contain more sophisticated code and many communicate with servers running even more sophisticated code behind that site. Most of the time these setups are not malicious, they merely make business easier and make websites more powerful, however there are a few bad apples who want to spoil it for everyone.
By taking advantage of vulnerabilities in your browser (different browsers all have different vulnerabilities and new ones are constantly being found as old ones are being patched) this code could move files onto your machine or access personal information, or something as simple as check through your history of visited websites.
I remember that there is a website out there that was designed to show you how easy it is for a website to look through your web history. I forget the URL, but basically when you visit it it displays the home page of every site that you have visited in a big collage. It pulls this information from your cookies, browser history and your cached website list without asking for your approval. It is a safe way of seeing how vulnerable your browser can be.
Turning off things like javascript can help, but a lot of websites rely on javascript to function correctly. Firefox has an add-on called noScript that will help you do that in a way that is less intrusive because you can set up a list of websites to allow javascript to function on, but really there is no way to guarantee that you won't get infected, you just need to take precautions.
Another thing is that you can run a limited user on your windows system instead of running it as an administrator because then a lot of this malicious code doesn't possess the necessary permissions to run against your system. Alternatively if you use some sort of UNIX-like OS then you just try not to operate day-to-day as the root user.
These are just my opinions obviously, I'm sure there is someone else here that can explain these things in more detail. This is after all a very tech-orientated forum community.