alert(frame2.document.getElementById("name").value);

解决方案 »

  1.   

    我是理解 是一个Iframe就是一个完整的DOM对象!
      

  2.   

    1楼正确 
    alert(frame2.document.getElementById("ID").value);
    不过要注意里面一定是id,不要写错掉了。
      

  3.   

    document.frames["frame2"].document....
      

  4.   

    OK谢谢大家 下班结贴
    有人回答一下我想问的一下ifram一个页时与window、doument的关系 是重新建立一个window对象和document对象么
      

  5.   

    window
    --document
    --iframe winodw
      --iframe document
    这样看能明白么?
      

  6.   

    发现了一个奇怪的问题两个iframe之间取值时
    window.parent.document.frame1.document.getElementById("iframe1Input").value=iframe2Input.value为什么frame1必须是name属性的值而不Id属性的值如果我写id的值 时就报取不到对象
      

  7.   

    getElementById就用ID,getElementByName就用Name
      

  8.   

    window.parent.document.frame1.document.getElementById("iframe1Input").value=iframe2Input.value我想问一个为什么 身一个document 可以省略而第二document不能省略
      

  9.   

    谢谢大家写了一个例子大家有兴趣看一下吧,希望对大家有点帮助
    <!--index.html-->
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <script language="javascript">
    function getValue(){
    alert(frame2.document.getElementById("iframe2Input").value)
    }
    </script>
    <BODY>
    <table>
    <tr><td colspan=2><input type="button" value="取值" onclick="getValue();"></td></tr>
    <tr><td><iframe src="frame1.html" name="frame1" id="frame1111"></iframe></td>
    <td><iframe src="frame2.html" name="frame2"></iframe></td>
    </tr>
    </table>
    </BODY>
    </HTML>
    <!--frame1.html -->
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <script language="javascript"></script>
    <BODY>
    <table>
    <tr><td colspan=2><input type="text" id="iframe1Input" ></td></tr>
    </table>
    </BODY>
    </HTML>
    <!--iframe2.html-->
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    </HEAD>
    <script language="javascript">
    function putValue(){
    alert(iframe2Input.value);
    window.parent.document.frame1.document.getElementById("iframe1Input").value=iframe2Input.value
    }
    </script>
    <BODY>
    <table>
    <tr><td colspan=2><input type="text" id="iframe2Input" onchange="putValue();"></td></tr></table>
    </BODY>
    </HTML>
      

  10.   

    DOM教程:
    http://www.w3pop.com/tech/school/htmldom/default.asp
      

  11.   

    这个教程是谁整理的,既然列出了兼容性,就应该把所有出现过的都列上,太不全了我最关注的contentWindow居然也没有
      

  12.   

    window.parent.document.frame1.document.getElementById("iframe1Input").value=iframe2Input.value我想问一个为什么 身一个document 可以省略而第二document不能省略有人回答一下这个问题么
      

  13.   

    window.frame1 或者 window.document.frames["frame1"]
     -> iframe window , 本质是window
    所以要接(window).document.getElementById("iframe1Input")
    也可以接(window).iframe1Input(用window.XXX限于id=XXX,window可以省略)window.document.all.frame1 或者 document.getElementById("frame1")
     -> iframe object本质是iframe这个html对象
    要接contentWindow或contentDocument指向iframe嵌套的window或window.document至于....document.frame1....个人认为这个document是语法错误,能运行就是容错性