用js控制内嵌页面中的元素的disabled属性,该如何写?在线等待

dingdangy 2003-01-27 01:02:46
B页面用<iframe></iframe>方式内嵌入A页面中,现需要在A页面中编写一JS程序来控制B页面中的input的disabled属性,该如何写?
我知道在B中可以通过parent.document.form[0].XXX.disabled = ture来控制A页面中元素的属性,反过来就不清楚了,请大家指导一下!谢谢。
...全文
281 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
dingdangy 2003-01-27
  • 打赏
  • 举报
回复
我的实现:
A页面(a.htm):
<html>
<head>
<title>A页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<script language="JavaScript">
<!--
function OnSelect()
{
if(document.forms[0].type.value == 01)
{
upload.document.forms[0].photo.disabled = false;
upload.document.forms[0].upload.disabled = false;
}
else
{
upload.document.forms[0].photo.disabled = true;
upload.document.forms[0].upload.disabled = true;
}
}
//-->
</script>
<table width="500" border="0" cellpadding="0" cellspacing="1" bgcolor="2070BF">
<tr align="center">
<td width="100" height="24" bgcolor="#99CCFF">是否可用</td>
<td height="24" bgcolor="#FFFFFF">
<select name="type" id="type" onclick="OnSelect()">
<option value="01">可用</option>
<option value="02">不可用</option>
</select>
</td>
<tr align="center">
<td width="100" height="48" rowspan="2" bgcolor="#99CCFF">上传文件</td>
<td height="24" bgcolor="#FFFFFF">
<iframe name="upload" frameborder=0 width=400 height=24 scrolling=no src=b.htm></iframe>
</td>
</tr>
</table>
</body>
</html>

B页面(b.htm):
<html>
<head>
<title>B页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body leftmargin="15" topmargin="2">
<form name="form" method="post" action="upfile.asp" enctype="multipart/form-data" >
<input name="photo" type="file" id="photo" size="42">
<input type="submit" name="upload" id="upload" value="上传">
</form>
</body>
</html>
dingdangy 2003-01-27
  • 打赏
  • 举报
回复
参考您提供的方法,并结合我自己的程序,已经成功,谢谢!
wangxj0600 2003-01-27
  • 打赏
  • 举报
回复
<input type=button

onclick="self.frames['a'].document.all.aaa.disabled=true">
<iframe name='a' src="2.htm"></iframe>

2.htm

<input type=button value="asdfd" id="aaa">

87,907

社区成员

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

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