您的位置:首页 > 产品设计 > UI/UE

关于使用docuemnt.write问题

2004-11-14 08:05 771 查看
先来看看这样一段代码:

<HTML>

<HEAD>

</script>

</HEAD>

<BODY>

Name:<input type="text" name="yidishui"/><br>

Age: <input type="text" name="yidishui1"/><br>

<input type="button" onclick="GetValue1()" value="call->GetValue1"/> <input type="button" onclick="GetValue2()" value="call->GetValue2"/>

</BODY>

</HTML> 

看上去两个函数达到的是同一个效果,但是不然。

调用函数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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: