If you try to use document.write from a window which has loaded completely it the page will be completely repainted with the new content. So it is better if you avoid the usage of document.write in your case.
Have a look at the below source code and see if this is what you are trying to achive.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled Document</title>
<style type="text/css">
#content{
width:900px;
height: 100px;
border:1px solid red;
background-color: #E1E1E2;
font-size:small;
font-family:Arial, Helvetica, sans-serif;
color:#77AFFC;
}
</style>
<script type="text/javascript">
function insertContent(str){
document.getElementById('content').innerHTML = str;
}
</script>
</head>
<body>
<div id="content"></div>
<form name="f">
<input type="button" value="Insert Content" onclick="insertContent('This is a test content');" name="insert" />
</form>
</body>
</html>
There is no point in using a subject not related to your acutal problem.
Hope this help.
Bookmarks