有两个iframe,是并列的,兄弟关系,怎么实现从一个iframe传递到另一个iframe,并刷新接收的iframe的页面?用ajax能实现吗?

解决方案 »

  1.   

    Untitle-1页面<!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=gb2312" />
    <title>无标题文档</title>
    <style type="text/css">
    div{
    background-color:#FF6600;
    }
    </style>
    <script type="text/javascript">
    function change(a){
    window.parent.document.getElementById("if2").contentWindow.show(a);
    }
    </script>
    </head><body>
    <input type="text" onblur="change(this.value)">
    </body>
    </html>
    Untitle-3页面<!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=gb2312" />
    <title>无标题文档</title>
    <script type="text/javascript">
    function show(a){
    document.getElementById("test").innerHTML=a;
    }
    </script>
    </head><body>
    <div id="test">11</div>
    </body>
    </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=gb2312" />
    <title>无标题文档</title>
    </head><body>
    <iframe src="Untitled-1.html" ></iframe>
    <iframe src="Untitled-3.html" id="if2"></iframe>
    </body>
    </html>大体这样试试  谷歌浏览器需要部署到服务器上
      

  2.   

    父页面弄个变量,两个页面都加个setTimeout来判断需要做什么
      

  3.   

    iframe加载的页面和其父页面是有引用关系的
    父页面中通过iframe.contentWindow可以访问iframe的页面,iframe页面中通过parent访问父页面,
    如果没有跨域,还可以互相操作dom所以兄弟页面之间也可以直接访问:
    var anotherWnd = window.parent.window.document.getElementById('iframeid').contentWindow;anotherWnd.location.href=anotherWnd.location.href;//刷新