This is known as XSS (cross-site scripting). It is a very serious security risk. Most good browsers will warn you if this is being attempted.
Andy, here are my recommendations.
1. If you're using Internet Exploder, STOP it now. It's FULL of vulnerabilities and weaknesses. Install Firefox. http://getfirefox.com
2. Install the AdBlock Plus plugin. Click Options, Filter Preferences, Filter subscriptions, untick "Allow some non intrusive advertising"
3. Install the Ghostery plugin. Run the wizard. Tell it to block everything.
4. Install an ad and malware blocking hosts file. http://someonewhocares.org/hosts/
is a very good one. Installation instructions are at the top of the file.
Once that is done, you'll never see another ad and your computer will be protected from 99% of the known malware, adware, tracking and foistware sites. You will be astonished at how much Ghostery in particular blocks (it pops up a list on each site you visit - you can disable this if you want.)
It's YOUR computer - take back control of it!