0

在使用 location.hash 提交之前,我将值从 1 个 iframe 传递到父窗口,它适用于 1 个 iframe,但我有 4 个 iframe,我需要将 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]

所有在提交表格之前。

谢谢

4

1 回答 1

1

框架 - 这里是框架 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);
于 2012-07-12T21:06:18.303 回答