如何设置另一个iframe的元素?

时间:2010-01-11 04:35:36

标签: javascript iframe

我正在尝试将元素从一个iframe设置为另一个。

window.iframes["test"].document.getElementById('lDownload').setAttribute('target',"_blank")
            //document.getElementById('lDownload').setAttribute('target',"_blank")
            window.iframes["test"].document.getElementById('lDownload').setAttribute('href',downloadFilename)
        }
        else
        {
            //noProcess();
            window.frames["test"].document.getElementById('lDownload').setAttribute('href',"javascript:noProcess()")                
        }

2 个答案:

答案 0 :(得分:1)

- 引用iframe javascript / document

parent.frames( “测试”)yourIframeFunction();

OR

parent.frames [0] .yourIframeFunction();

- 引用父/顶级文档的javascript /文档

parent.yourMainDocumentFunction();

答案 1 :(得分:1)

- 重新加载iframe内容


countRefreshes = 0;
function refreshIframe(which) {
    var currHref = '' + parent.frames[which].location + '';
    parent.frames[which].location.href = currHref + '?c=' + countRefreshes + '';
    countRefreshes++;
}