最近刚学写。 我想在javascript里用document.write()输出一句话到静态页面而(不改变原页面只添加在最后),但我输出
是单独显示,页面的东西都没了。 要怎么写

解决方案 »

  1.   

    var divNew = document.createElement("DIV")
    document.body.appendChild(divNew);
    divNew.innerHTML = "My Text!";
      

  2.   

    document.body.innerHTML+="往 页面添加的html";ps:当window.load之后 ,调用document.write方法,会新建输出流,导致在新的页面中输出
      

  3.   

    <body>
    <p>1111</p>
    <input type="button" value="print text" onclick="abc()">
    </body><script>
    function abc()
    {
    bdhtml=window.document.body.innerHTML;
    window.document.body.innerHTML=bdhtml +"<p>aaaa</p>"
    }
    </script>