mainFrame.document.getElementById("你需要获取的控件的ID")

解决方案 »

  1.   

    不行  返回 NULL··
      

  2.   

    parent.mainFrame.document.getElementById("你需要获取的控件的ID")
      

  3.   

    还是不对,我那页面就一个iframe 没有大框架,我是提交后 还是提交到本页面来取的
      

  4.   

    <td width="440" align="left" valign="top" >
    <iframe width=520 height=400 name="mainFrame" id="mainFrame" src="xxxxx.html"  border=0  scrolling=no> </iframe>
    </td> 
    <script language =  javascript>
      window.onload   =   function(){   
      alert(window.mainFrame.document.all.xxxxx.value);   
      }
    </script>
    测试过了 可以
    window.mainFrame.document.all.xxxxx.value
      

  5.   

    <td width="440" align="left" valign="top" >
    <iframe width=520 height=400 name="mainFrame" id="mainFrame" src="xxxxx.html"  border=0  scrolling=no> </iframe>
    </td> 
    <script language =  javascript>
      window.onload   =   function(){   
      alert(window.mainFrame.document.all.xxxxx.value);   
      }
    </script>
    测试过了 可以
    window.mainFrame.document.all.xxxxx.value
      

  6.   


    <!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=utf-8" />
    <title>无标题文档</title>
    <script>
    window.onload=function(){alert(mainFrame.document.getElementById("test").value);};
    </script>
    </head>
    <body>
    <iframe width=520 height=400 name="mainFrame" id="mainFrame" src="tt.html"  border=0  scrolling=no> </iframe> 
    </body>
    </html>tt.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=utf-8" />
    <title>无标题文档</title>
    </head><body>
    <input id="test" name="test" value="测试"/>
    </body>
    </html>
      

  7.   

    是不是你iframe中的代码有问题呀。
    把代码帖出来看看吧。