<HTML>
<HEAD>
<Title>Write to subwindow.</Title>
<Script language="JavaScript">
var newWindow
function makeNewWindow()
{
    newWindow=window.open("","","status,height='200',width='300'");
}
    function subWrite()
    {
      if(newWindow.closed){       makeNewWindow;
var newContent="<HTML><HEAD><Title>A new doc.</Title><HEAD>";
newContent+="<Body BGCOLOR='coral'><H1>This document is brand new.</h1>";
newContent+="Click the back button to see original document.";
newContent+="</Body></HTML>";
newWindow.document.write(newContent);
newWindow.documemt.close();
}
    }
</Script>
</HEAD>
<body onLoad="makeNewWindow()">
<Form>
<input type="button" value="Write to Subwindow" onClick="subWrite()">
</Form>
</body>
</HTML>

解决方案 »

  1.   

    修整一下,你里边的错误太多了!还有个地方没改正!
    <HTML>
    <HEAD>
    <Title>Write to subwindow.</Title>
    <Script language="JavaScript">
    var newWindow
    function makeNewWindow()
    {
        newWindow=window.open("","","status,height='200',width='300'");
    }
        function subWrite()
        {
          if(newWindow.closed){       
           makeNewWindow();
    var newContent="<HTML><HEAD><Title>A new doc.</Title><HEAD>";
    newContent+="<Body BGCOLOR='coral'><H1>This document is brand new.</h1>";
    newContent+="Click the back button to see original document.";
    newContent+="</Body></HTML>";
    newWindow.document.write(newContent);
    newWindow.document.close();
    }
        }
    </Script>
    </HEAD>
    <body onLoad="makeNewWindow()">
    <Form>
    <input type="button" value="Write to Subwindow" onClick="subWrite()">
    </Form>
    </body>
    </HTML>
      

  2.   

    if(newWindow.closed)       

        makeNewWindow()
    }
    ----xxuu503: 加了,還是有錯.
      

  3.   

    "VAR"要小写:
    <HTML>
    <HEAD>
    <Title>Write to subwindow.</Title>
    <script language="JavaScript">
      var newWindow
      
      function makeNewWindow(){
        newWindow=window.open("","","status,height='200',width='300'");
      }
      
      function subWrite(){
          
      if(newWindow.closed){
         makeNewWindow();
             var newContent="<HTML><HEAD><Title>A new doc.</Title><HEAD>";
             newContent+="<Body BGCOLOR='coral'><H1>This document is brand new.</h1>";
             newContent+="Click the back button to see original document.";
             newContent+="</Body></HTML>";
             newWindow.document.write(newContent);
             newWindow.documemt.close();
      }
      }
    </script>
    </HEAD>
    <body onLoad="makeNewWindow()">
    <Form>
    <input type="button" value="Write to Subwindow" onClick="subWrite()">
    </Form>
    </body>
    </HTML>
      

  4.   

    ===> VAR newContent="<HTML><HEAD><Title>A new doc.</Title><HEAD>"
    这里除了你的代码都是可以运行的,不知你想要什么样的结果?
      

  5.   

    真笨,改VAR 為var;
    newWindow.documemt.close()
    改為:
    newWindow.document.close()