1.不是必须
2.因为是字符串所以要用引号
  用单引号或双引号都可以
3.这是个构造函数
  建立对象就这样一种固定的方法,前提是已经定义了相应的类
 new就是用来创建对象的

解决方案 »

  1.   

    对于第一个问题,写和不写是有很大区别的
    比如,内容都是document.write出来的,不document.close,ie会一直显示下载,也就不会触发onload时间。
      

  2.   

    这段代码是我用来测试document.close()的,为什么里面的onload事件还是不能触发呢?
    看不出错在哪里了?
    <html>
    <head>
    <script>
    function open_new_win()
    {
      var message = "the document writing output has been closed!"
      var my_win = window.open("","","width=300,height=300")
      my_win.document.writeln("<html>")
      my_win.document.writeln("<head>")
      my_win.document.writeln("</head>")
      my_win.document.writeln('<body onLoad="alert(message)">')
      my_win.document.writeln("this is a test to see whether the closure of the document is necessary!")
      my_win.document.writeln("</body>")
      my_win.document.writeln("</html>")
      my_win.document.close()
    }
    </script>
    </head>
    <body>
    <input type="button" value="test" onClick="open_new_win()">
    </body>
    </html>
      

  3.   

    <html>
    <head>
    <script>
    function open_new_win()
    {
      var message = "the document writing output has been closed!"
      var my_win = window.open("","","width=300,height=300")
      my_win.document.writeln("<html>")
      my_win.document.writeln("<head>")
      my_win.document.writeln("</head>")
      my_win.document.writeln('<scri'+'pt>alert("test");var message="the document writing output has been closed!";</scri'+'pt>')
      my_win.document.writeln('<body onLoad="alert(message)">')
      my_win.document.writeln("this is a test to see whether the closure of the document is necessary!")
      my_win.document.writeln("</body>")
      my_win.document.writeln("</html>")
      my_win.document.close()
    }
    </script>
    </head>
    <body>
    <input type="button" value="test" onClick="open_new_win()">
    </body>
    </html>
      

  4.   

    my_win.document.writeln('<body onLoad="alert(message)">')
    改为
    my_win.document.writeln('<body onLoad="alert(\'message\')">')
    原行在弹出窗口里写入<body onLoad="alert(message)"> 而message并未定义,出错了所以不弹出对话框