B页面用
方式内嵌入A页面中,现需要在A页面中编写一JS程序来控制B页面中的input的disabled属性,该如何写?
我知道在B中可以通过parent.document.form[0].XXX.disabled = ture来控制A页面中元素的属性,反过来就不清楚了,请大家指导一下!谢谢。
---------------------------------------------------------------
方法一:
1<input onclick="self.frames['a'].document.all.aaa.disabled=true" type="button"/>
1<iframe name="a" src="2.htm"></iframe>
2.htm
1<input id="aaa" type="button" value="asdfd"/>
-------------------------------------------------------------------
方法二:
A页面(a.htm):
1<html>
2<head>
3<title>A页面</title>
4<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
5</head>
6<body>
7<script language="JavaScript">
8<!--
9function OnSelect()
10{
11if(document.forms[0].type.value == 01)
12{
13upload.document.forms[0].photo.disabled = false;
14upload.document.forms[0].upload.disabled = false;
15}
16else
17{
18upload.document.forms[0].photo.disabled = true;
19upload.document.forms[0].upload.disabled = true;
20}
21}
22//-->
23</script>
24<table bgcolor="2070BF" border="0" cellpadding="0" cellspacing="1" width="500">
25<tr align="center">
26<td bgcolor="#99CCFF" height="24" width="100">是否可用</td>
27<td bgcolor="#FFFFFF" height="24">
28<select id="type" name="type" onclick="OnSelect()">
29<option value="01">可用</option>
30<option value="02">不可用</option>
31</select>
32</td>
33<tr align="center">
34<td bgcolor="#99CCFF" height="48" rowspan="2" width="100">上传文件</td>
35<td bgcolor="#FFFFFF" height="24">
36<iframe frameborder="0" height="24" name="upload" scrolling="no" src="b.htm" width="400"></iframe>
37</td>
38</tr>
39</tr></table>
40</body>
41</html>
B页面(b.htm):
1<html>
2<head>
3<title>B页面</title>
4<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
5</head>
6<body leftmargin="15" topmargin="2">
7<form action="upfile.asp" enctype="multipart/form-data" method="post" name="form">
8<input id="photo" name="photo" size="42" type="file"/>
9<input id="upload" name="upload" type="submit" value="上传"/>
10</form>
11</body>
12</html>