问题描述:
        我在一个iframe中嵌入了一个页面,我想实现的效果是,点击一个按钮使这个iframe内嵌的页面能够完全转到一个新打开的页面中,同时那个iframe隐藏,再点击 一下那个按钮,新页面转到iframe的内嵌页面,不晓得是否可以实现?

解决方案 »

  1.   


    <iframe id="ifm" ></iframe>
    <input type="button" onclick="ifm.style.display='none';var own = window.open(ifm.src,null,'');" value="out"><input type="button" value="iner" onclick="own.close();ifm.style.display='';">
      

  2.   

    我的问题的关键在于
    如何使在iframe里面的那个页面不要关闭。
    自己想想觉得不可能。
      

  3.   

    如果就这两个页面转来转去,需要写函数。给你参考一个函数,这个函数的功能是,打开iframe,并指定页面,如果按钮再触发这个函数,如果页面没有换新地址,那么iframe就隐藏,下次点击再打开,如果是打开的情况,按钮触发这个函数并换新地址,那iframe不会关闭,会继续访问新地址。
    //框架函数区
    //通用打开子iframe
    function Open_iframe(ID,URL)
    {
    //<iframe> 判断 顶部展开区 or 子展开区
    if( ID == 'iframe_top' )
    {
    //判断对象
    if( !window.document.getElementById('table_iframe_top') ){return;}
    if( !window.frames['iframe_top'] ) {return;}
    //声明对象
    var Display = window.document.getElementById('table_iframe_top');
    var Iframe = window.frames['iframe_top'];
    }
    else
    {
    //判断对象
    if( !window.document.getElementById('trIframe_'+ID) ){return;}
    if( !window.frames['iframe_'+ID] ) {return;}
    //声明对象
    var Display = window.document.getElementById('trIframe_'+ID);
    var Iframe = window.frames['iframe_'+ID];
    }
    //-- //处理
    if( Display.style.display=='none' )
    {
    Display.style.display='';
    if( Iframe.location.href.indexOf(URL) < 0 ) //避免重复操作,节省资源
    {Iframe.location.href=URL;}
    }
    else
    {
    if( Iframe.location.href.indexOf(URL) < 0 )
    {Iframe.location.href=URL;}
    else
    {Display.style.display='none';}
    }

    //主框架Iframe自适应纵向滚动条
    window.parent.MainFrame_AutoScroll(null);
    }