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

框架集中对元素的访问的问题
文档一 frameindex.html
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<frameset rows="60,*" cols="*" frameborder="yes" border="1" framespacing="2">
 <frame src="framehead.html" name="topframe" scrolling="yes" noresize="noresize">
  <frameset rows="*" cols="192,*" framespacing="2" frameborder="yes" border="1">
  <frame src="frameleft.html" name="leftframe" scrolling="yes" noresize="noresize">
  <frame src="frameright.html" name="zhu" id="zhu">
  </frameset>

</frameset><noframes></noframes><noframe>
<body>
我的框架没有成功
</body>
</noframe>
</html>


文档二frameleft.html
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function content()
{ parent.frames["zhu"].document.close();
  parent.frames["zhu"].document.write("我一次次的离开,是为了一次次的回来")
}
</script>
</head>

<body>
<p> <a href="#" onclick="content()">徐志摩</a></p>
</body>
</html>


上面文档是一个框架集,框架集分上下两部分,下部分又分左右两部分。当我单击"徐志摩"时,parent.frames["zhu"].document.write("我一次次的离开,
是为了一次次的回来")执行,向frameright.html写入。当此句parent.frames["zhu"].document.close()不使用时,单击一次"徐志摩",就会向frameright.html写入一次;
当我启用这句时,再次单击"徐志摩",frameright.html没有任何变化。
问题:
document.write()方法执行时,框架集中frameright.html作为一个窗口应刷新一次.之前frameright.html写入的就不成在了,所以document.close()没必要使用,这儿怎么不适用??

------解决方案--------------------
修改内容还是使用div.innerHTML="xx"比较好