JavaScript: Why do document.write failed with 'no privilige'?
<pre><code>&lt;html&gt;
 &lt;head&gt;
  &lt;style type="text/css"&gt;
   #navigator a {
    display: none;
   }
  &lt;/style&gt;

  &lt;script type="text/javascript"&gt;
   function view() {
    var a = document.getElementsByTagName("a");
    for (var i = 0; i &lt; a.length; i++)
     alert(a[i].innerHTML);
    for (var i = 0; i &lt; a.length; i++) 
     document.write(a[i].innerHTML);
   }
  &lt;/script&gt;
 &lt;/head&gt;
 &lt;body&gt;
  &lt;div id="navigator" class="navigator"&gt;
   &lt;div class="menu"&gt;
    Programming Language
    &lt;a href=""&gt;C&lt;/a&gt;
    &lt;a href=""&gt;C++&lt;/a&gt;
    &lt;a href=""&gt;Java&lt;/a&gt;
    &lt;button type="button" onclick="view()"&gt;View&lt;/button&gt;
   &lt;/div&gt;
  &lt;/div&gt;
 &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p><code>alert</code> worked fine. <code>document.write</code> succeed with the first element 'C' but failed with the next two element.</p>

<p>Why did document.write fail with 'no privilige'?</p>

<p>Thanks.</p>
