document.write() takes a string as a parameter and essentually writes what it's given inplkace of itself wherever it occures in the page. It should never be called after a page is loaded (such as in an event handler attribute) because it will write over the current page (erasing the current page).
Examples:
The code (the '\' is an escape character, allowing me to write the code so it validates 100%):
<h1>
<script type="text/javascript">
var title="Gettysburg Address";
document.write('<span style="color:red">'+title+'<\/span>');
</script>
</h1>
<!--Above, differently-->
<script type="text/javascript">
var title="Gettysburg Address";
document.write('<h1><span style="color:red">'+title+'<\/span><\/h1>');
</script>
<p> Four score and seven...
<script type="text/javascript">
document.write('<br />=P document.write() wUz HeRe!! =P<br />');
</script>
...from the earth.
</p>
<button onclick="document.write('page trashed')">
Click to trash this page
</button>