title: Could someone explain why this document.write overwrites the entire page?
body: <p>Here is the code; javascript </p>
  
  <pre><code>function Roll()
       // Results: displays a randomly selected image of a 6-sided die
       {
         var roll;
  
         roll = RandomInt(1, 6);
  
         if (roll == 1) {
           document.getElementById("die").src = 
               "die1.gif";
           document.write("&lt;center&gt;&lt;p&gt;&lt;a href='bad.html'&gt; Enter &lt;/a&gt;&lt;/p&gt;&lt;/center&gt;");
         }
         else if (roll == 2) {
           document.getElementById("die").src = 
               "die2.gif";
           document.write("&lt;center&gt;&lt;p&gt;&lt;a href='good.html'&gt; Enter &lt;/a&gt;&lt;/p&gt;&lt;/center&gt;");
         }
         else if (roll == 3) {
           document.getElementById("die").src = 
               "die3.gif";
           document.write("&lt;center&gt;&lt;p&gt;&lt;a href='bad.html'&gt; Enter &lt;/a&gt;&lt;/p&gt;&lt;/center&gt;");
         }
         else if (roll == 4) {
           document.getElementById("die").src = 
               "die4.gif";
           document.write("&lt;center&gt;&lt;p&gt;&lt;a href='good.html'&gt; Enter &lt;/a&gt;&lt;/p&gt;&lt;/center&gt;");
         }
         else if (roll == 5) {
           document.getElementById("die").src = 
               "die5.gif";
           document.write("&lt;center&gt;&lt;p&gt;&lt;a href='bad.html'&gt; Enter &lt;/a&gt;&lt;/p&gt;&lt;/center&gt;");
         }
         else {
           document.getElementById("die").src = 
               "die6.gif";
           document.write("&lt;center&gt;&lt;p&gt;&lt;a href='good.html'&gt; Enter &lt;/a&gt;&lt;/p&gt;&lt;/center&gt;");
         }
       }
  </code></pre>
  
  <p>And here is the Jsfiddle <a href="http://jsfiddle.net/seymorevenue/TcNF7/" rel="nofollow">http://jsfiddle.net/seymorevenue/TcNF7/</a> (though document.write doesn't seem to work there, and the dice images arn't up)
  I don't think I really understand the Document.write statement, and is there a better method? All I want to do is roll a die and display a link based on the result. Thanks for any help</p>