日期:2014-05-18  浏览次数:20642 次

关于利用javaScript引用框架中的控件的问题
页面结结构是这样的, 


HTML code
WebForm1.aspx
...
<td >
<iframe id="pM" src=WebForm4.aspx frameborder =0 style="WIDTH: 100%; HEIGHT: 100%">
</iframe>
</td>

WebForm4.aspx
<frameset id=fraMain cols="20%,*">
  <frame id=fralist src="imagelist.aspx">
  <frameset rows="40%,*">
  <frame src="">
  <frame src="">
  </frameset>
</frameset>


imagelist.aspx
...
<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0" scroll="no">
  <form id="Form1" method="post" runat="server">
  <select id="listbox1" size="2" name="fdsfds" style="WIDTH: 100%; HEIGHT: 100%">
  <OPTION value=""></OPTION>
  </select>
  </form>
</body>
...


我怎么才能在WebForm1.aspx中引用到 imagelist.aspx 中的 listbox1? 
比如这样document.pM.document.fralist.document.listbox1 
可是实际上不行。

------解决方案--------------------
firefox 中获取listbox1的方法

document.getElementById("pM").contentDocument.getElementById('fralist').contentDocument.getElementById('ListBox1') 


IE中的方法

document.all.pM.document.frames[0].frames["fralist"].document.getElementById('ListBox1')