关于在父页面监听iframe内部元素变化,然后触发事件的问题

飞翔的大麦茬 2006-04-12 03:42:32
不能修改iframe的页面,只能在父页面中监听
哪位兄弟熟悉的,麻烦告知,谢谢...

例如在11.html页面中怎么写脚本,监听两个“radiobutton”的选择事件
11.html
----------<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<table width="75%" height="70" border="0" cellpadding="0" cellspacing="0">
<tr>
<td> <div style="padding-left:100;padding-top:0">
<iframe src="22.htm" style="width:400;height:100;over-flow:clip" id="frame2" ></iframe>
</div></td>
</tr>
</table>
</body>
</html>

22.html
-------------------------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<form name="form1" method="post" action="">
<input type="radio" name="radiobutton" value="1">
<input name="radiobutton" type="radio" value="2" checked>
<input type="text" name="textfield">
</form>
</body>
</html>

...全文
2143 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
有来有往 2006-07-17
  • 打赏
  • 举报
回复
写的再具体一些啊 要是想得到radio里的值 该怎么写
GaoXX 2006-04-15
  • 打赏
  • 举报
回复
顶一下
飞翔的大麦茬 2006-04-12
  • 打赏
  • 举报
回复
不在同一个域?
不太理解楼上大哥的意思
只是因为iframe里的页面是公共页面,修改了,那会影响到很多地方
所以才有这个要求
hbhbhbhbhb1021 2006-04-12
  • 打赏
  • 举报
回复
既然你不能修改IFRAME里的内容,是不是说你的iframe和你的主页面不在同一个域,那样的话就难办了。
如果在同一个域下到是可以实现
飞翔的大麦茬 2006-04-12
  • 打赏
  • 举报
回复
楼上的兄弟,请仔细看一下我的说明,我不要对iframe的src对应的页面做任何变动
ybcola 2006-04-12
  • 打赏
  • 举报
回复
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<form name="form1" method="post" action="">
<input type="radio" name="radiobutton" id="radiobutton" value="1" onclick="parent.radiobuttonclick()">
<input name="radiobutton" type="radio" value="2" checked>
<input type="text" name="textfield">
</form>
</body>
</html>

----------<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language="javascript">
var fram2=document.getElementById("frame2").contentWindow;
alert(fram2.from1.radiobutton.checked);
或者这句写成
alert(fram2.docuemt.getElementByid("radiobutton").checked);
</script>
</head>

<body>
<table width="75%" height="70" border="0" cellpadding="0" cellspacing="0">
<tr>
<td> <div style="padding-left:100;padding-top:0">
<iframe src="22.htm" style="width:400;height:100;over-flow:clip" id="frame2" ></iframe>
</div></td>
</tr>
</table>
</body>
</html>

87,997

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧