日期:2014-05-16  浏览次数:20321 次

请教一个小问题
<html>
<head>
<script>
var   w;
function   debug(msg)
{
        if     (w==null)
        {
                      var   w=window.open( " ", "win1 ", "width=600,height=300,resizable ");
                      var   t=w.document.open( "text/plain ");
  }

  t.writeln(msg);
}
</script>
<title> Untitled   Document </title>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 ">
</head>

<body   bgcolor= "#FFFFFF "   text= "#000000 ">
<input   type= "button "   name= "button1 "   value= "push   me "   onclick= "debug( 'you   have   push   me '); ">
</body>
</html>

但是无论我点几次button,文本文件上只显示一次 'you   have   push   me '。但是我并没有t.close(),所以我点一次按钮应该可以每次都写到t所代表的文本文件上啊。错在哪里,请高手指点

------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME= "Generator " CONTENT= "EditPlus ">
<META NAME= "Author " CONTENT= " ">
<META NAME= "Keywords " CONTENT= " ">
<META NAME= "Description " CONTENT= " ">
<script>
var w;
var tempstr= " "
function debug(msg)
{
if (w==null)
{
var w=window.open( " ", "win1 ", "width=600,height=300,resizable ");
var t=w.document.open( "text/plain ");
}
tempstr = tempstr + msg + " ";
t.write(tempstr);
}
</script>
</head>
<body bgcolor= "#FFFFFF " text= "#000000 ">
<input type= "button " name= "button1 " value= "push me " onclick= "debug( 'you have push me '); ">
</body>
</html>
</BODY>
</HTML>