在提交之前将值从多个iframe传递到父窗口


Passing value from multiple iframes to parent window before submit

在使用location.hash提交之前,我将从1个iframe向父窗口传递值。它非常适用于1个ifame,但我有4个iframes,我需要将这些iframe分开:

Iframe1我有:

<script language="javascript">
    function update(val) {
     parent.location = document.referrer + "#" + val
}
</script>

我的父母:

<script type="text/javascript">
var val="";
function passVal(){
    if(location.hash != val){
    val = location.hash;
    val = val.substring(1, val.length);
    document.form.val.value=val;
   }
}
setInterval(passVal,200);
</script>

在1个iframe中完美工作-在提交之前,如何将4个不同iframe的值传递给1个父窗口?例如:

iframe 1 - VAL1 -> parent.window [field1]
iframe 2 - VAL2 -> parent.window [field2]   
iframe 3 - VAL3 -> parent.window [field3]
iframe 4 - VAL4 -> parent.window [field4]

所有提交表格之前。

感谢

帧-此处为帧1

function update(val) {
   parent.location = document.referrer + "#field1:" + val
}

var val="";
function passVal(){
    if(location.hash != val){
    val = location.hash;
    val = val.substring(1, val.length);
    var parts=val.split(":");
    document.formname.elements[parts[0]].value=parts[1];
   }
}
setInterval(passVal,200);