javascript:在写入之前等待加载iframe页面(但不是从触发加载的页面)

javascript:在写入之前等待加载iframe页面(但不是从触发加载的页面),javascript,iframe,Javascript,Iframe,抱歉,如果这已经回答了其他地方,但我还没有找到它的参考。(我承认,可能是因为没有其他人愿意做这种愚蠢的事) 因此,我有一个包含三个iframe的页面。一个iFrame上的事件触发javascript函数,该函数将新页面加载到其他两个iFrame中;['topright']和['bottomright'] 但是,加载到iframe“topright”中的页面中的javascript需要向“bottomright”iframe中的元素发送信息 window.frames['bottomright']

抱歉,如果这已经回答了其他地方,但我还没有找到它的参考。(我承认,可能是因为没有其他人愿意做这种愚蠢的事)

因此,我有一个包含三个iframe的页面。一个iFrame上的事件触发javascript函数,该函数将新页面加载到其他两个iFrame中;['topright']和['bottomright']

但是,加载到iframe“topright”中的页面中的javascript需要向“bottomright”iframe中的元素发送信息

window.frames['bottomright'].document.subform.ID\u client=client; 等

但只有当页面完全加载到右下角的框架中时,这才有效。那么,对于“topright”iframe中的代码来说,什么是最有效的方法来检查并确保右下角框架中的表单元素在写入之前实际上是可以写入的呢?记住页面加载不是从右上角的框架触发的,所以我不能简单地使用onLoad函数


(我知道这听起来像是一条从一个页面到另一个页面获取数据的可怕的曲折路线,但那是另一回事。客户端总是对的,等等…:-)

如果我正确理解您的问题,并且您控制所有帧的内容,并且所有帧内容都来自同一个域,您可以在
bottomright
框架上触发
onload
事件,从
topright
中提取数据,而不是尝试推送数据

bottomright
甚至可以调用
topright
中的函数,并要求它推送数据(在我看来,这仍然是一种拉取形式)

大概是这样的:

// topright
function pushData(frame, form, name, value) {
    frame.document.forms[form].elements[name] = value;
}

// bottomright
window.onload = function () {
    top.frames['topright'].pushData(window, 'sub_form', 'ID_client', 'client');
}
未经测试。我不能100%确定从
bottomright
传递
window
是否有效,在这种情况下,这可能是另一种选择:

// topright
function pushData(frame, form, name, value) {
    top.frames[frame].document.forms[form].elements[name] = value;
}

// bottomright
window.onload = function () {
    top.frames['topright'].pushData('bottomright', 'sub_form', 'ID_client', 'client');
}