为什么这样写就能输出
 function reWrite(){
    // assemble content for new window
    var newContent = "<html><head><title>A New Doc</title></head>"
    newContent += "<body bgcolor='aqua'><h1>This document is brand new.</h1>"
    newContent += "Click the Back button to see original document."
    newContent += "</body></html>"
    // write HTML to new window document
    document.write(newContent)
    document.close() // close layout stream
  }

解决方案 »

  1.   

    js不支持字符串换行的
    var newContent = "<html><head><title>A New Doc</title></head><body bgcolor='aqua'><h1>This   document is brand new.</h1>Click the Back button to see original document.</body></html>";这样不换行是可以的 如想换行需要连接符
    var newContent = "<html><head><title>A New Doc</title></head><body bgcolor='aqua'>"+
    "<h1>This   document is brand new.</h1>"+
    "Click the Back button to see original document.</body>"+
    </html>";
      

  2.   

    var newContent = "<html><head><title>A New Doc</title></head><body bgcolor='aqua'>"+
    "<h1>This   document is brand new.</h1>"+
    "Click the Back button to see original document.</body>"+
    "</html>";