如何通过javascript获得上层frame的一个document对象?详见帖内 问题2:可以共享么?=============================== CSDN小助手 是一款脱离浏览器也可以使用csdn论坛的软件! 界面: http://qqwwee.com/ 下载: http://qqwwee.com/csdn.rar 包含源代码 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 要共享变量的话可以考虑把变量放到globla.asa文件 这种Iframe访问上层框架中的函数是可以的,下面给出例子,总共四个文件,保存成Html文件,放到同一目录,运行Frame.html即可显示效果:++++++++++++++++++++++++++++++++++++++++++frame.html++++++++++++++++++++++++++++++++++++++++++<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>Frame</title></head><frameset cols="450,*" frameborder="no" border="0" framespacing="0"> <frame src="1.html" name="left" scrolling="No" noresize="noresize" id="left" title="leftFrame" /> <frame src="2.html" name="main" frameborder="yes" bordercolor="#000000" id="main" title="main" /></frameset><noframes><body></body></noframes></html>+++++++++++++++++++++++++++++++++++++++++++1.html+++++++++++++++++++++++++++++++++++++++++++<!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>1</title><script type="text/javascript">function xlh(a,b){if(arguments.length==1){ alert("我是2.html,调用的1.html中的函数");}else{ alert("我是iframe 3.html,调用的1.html中的函数");}}</script></head><body><input type="text" id="ltxt" size="50" /><br /><br /><iframe src="3.html" name="ifr" width="400" height="100"></iframe><br></body></html>+++++++++++++++++++++++++++++++++++++2.html+++++++++++++++++++++++++++++++++++++<!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>2</title></head><body><input type="text" id="mtxt" size="50" /><br /><br /><input type="button" onclick="parent.left.xlh(1);" value="调用左侧框架中的函数"></body></html>+++++++++++++++++++++++++3.html+++++++++++++++++++++++++<!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>3</title><script type="text/javascript"> function ifr(){ top.left.document.getElementById("ltxt").value = "Iframe 3.html 生成的值 ltxt"; top.main.document.getElementById("mtxt").value = "Iframe 3.html 生成的值 mtxt"; }</script></head><body onload="ifr()"><input type="button" value="我是Iframe,调用左侧框架中的函数" onclick="parent.parent.left.xlh(1,1);" /></body></html> 同时上例在IE6.0 sp2 + Mozilla Firefox 1.5 测试通过! 关于js 获取页面元素的绝对坐标的问题 Dialog对话框点了取消,如何清除掉输入的内容? eval方法如何传递执行函数的参数 一个文本框内输入一个数字,列表定位成相应的选项。这个文本框的数字和列表的value的值对应。 问一下关于js代码的问题 如何打开一个颜色对话框? 怎么样刷新上一页面??? 抗议 CSDN!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 怎样打开一文件 关于Jquery的元素parent.remove()问题 急切等待富文本框的问题 如何用javascript在客户端连接ORACLE10数据库?
frame.html
++++++++++++++++++++++++++++++++++++++++++<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Frame</title>
</head><frameset cols="450,*" frameborder="no" border="0" framespacing="0">
<frame src="1.html" name="left" scrolling="No" noresize="noresize" id="left" title="leftFrame" />
<frame src="2.html" name="main" frameborder="yes" bordercolor="#000000" id="main" title="main" />
</frameset>
<noframes><body>
</body>
</noframes></html>
+++++++++++++++++++++++++++++++++++++++++++
1.html
+++++++++++++++++++++++++++++++++++++++++++<!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>1</title>
<script type="text/javascript">
function xlh(a,b){
if(arguments.length==1){
alert("我是2.html,调用的1.html中的函数");
}else{
alert("我是iframe 3.html,调用的1.html中的函数");
}}
</script>
</head><body>
<input type="text" id="ltxt" size="50" /><br /><br />
<iframe src="3.html" name="ifr" width="400" height="100"></iframe><br>
</body>
</html>+++++++++++++++++++++++++++++++++++++
2.html
+++++++++++++++++++++++++++++++++++++<!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>2</title>
</head><body>
<input type="text" id="mtxt" size="50" /><br /><br />
<input type="button" onclick="parent.left.xlh(1);" value="调用左侧框架中的函数">
</body>
</html>+++++++++++++++++++++++++
3.html
+++++++++++++++++++++++++<!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>3</title>
<script type="text/javascript">
function ifr(){
top.left.document.getElementById("ltxt").value = "Iframe 3.html 生成的值 ltxt";
top.main.document.getElementById("mtxt").value = "Iframe 3.html 生成的值 mtxt";
}
</script>
</head><body onload="ifr()">
<input type="button" value="我是Iframe,调用左侧框架中的函数" onclick="parent.parent.left.xlh(1,1);" />
</body>
</html>