先来看看这样一段代码:

关于使用docuemnt.write问题<HTML>
关于使用docuemnt.write问题
<HEAD>

关于使用docuemnt.write问题    
<!--Begin Code
关于使用docuemnt.write问题    
//******************
关于使用docuemnt.write问题
    //取得两个text的value 并写在页面上
关于使用docuemnt.write问题
    //******************
关于使用docuemnt.write问题
    function GetValue1()
{
关于使用docuemnt.write问题    document.write(
"Name:"+yidishui.value);
关于使用docuemnt.write问题    document.write(
"Age:"+yidishui1.value);
关于使用docuemnt.write问题    }

关于使用docuemnt.write问题
function GetValue2()
{
关于使用docuemnt.write问题    
var name=yidishui.value;
关于使用docuemnt.write问题    
var age=yidishui1.value;
关于使用docuemnt.write问题       document.write(
"Name:"+name);
关于使用docuemnt.write问题    document.write(
"Age:"+age);
关于使用docuemnt.write问题}

关于使用docuemnt.write问题    
//End Code
关于使用docuemnt.write问题
    // -->
关于使用docuemnt.write问题
</script>
关于使用docuemnt.write问题
</HEAD>
关于使用docuemnt.write问题
<BODY>
关于使用docuemnt.write问题Name:
<input type="text" name="yidishui"/><br>
关于使用docuemnt.write问题Age:
&nbsp;<input type="text" name="yidishui1"/><br>
关于使用docuemnt.write问题
<input type="button" onclick="GetValue1()" value="call->GetValue1"/>&nbsp;<input type="button" onclick="GetValue2()" value="call->GetValue2"/>
关于使用docuemnt.write问题
</BODY>
关于使用docuemnt.write问题
</HTML> 
关于使用docuemnt.write问题


看上去两个函数达到的是同一个效果,但是不然。
调用函数GetValue1()运行是达不到效果,欢鳪etValue2()可以实现



===============
调用GetValue1() 是出现错误原因   在使用了第二个 是document.write()出错  ,此时的yidishui1对象已经不存在了,因为使用第一个docuemnt.wrte()时重写了整个页面,所以用的二个时yidishui1对象不存在了!!!
大家可以看看英文对docuemnt.write()的解释:

You should not use the write or writelen methods on the current document after the document has finished loading unless you first call the open method, which clears the current document's window and erases all variables

相关文章: