日期:2014-05-16  浏览次数:20331 次

在子窗体给自已提交一次以后,给父窗体转值,
问个问题,
在父窗体有一个,
<input type="hidden" name="s" id="s" value="0"/>

在这个窗体上弹出一个小子窗体,
并选择一个控件操作,
然后再确定,提交到本子窗体,
这时运行JS
<script>
window.parent.document.getElementById("s").value=s;

</script>

这时提示错误:
window.parent.document.getElementById("。。。")
是空或者NULL
这个该怎么解决?

------解决方案--------------------
window.showModalDialog( url,window,...);
如果是用模式对话框打开新窗口,可以这样
在子窗口中
var pWin = top.parent.dialogArguments;
        pWin.document.getElementById("。。。");

------解决方案--------------------
看看id对不
------解决方案--------------------
看一下窗体是iframe 还是open出来的新窗口;要是新窗口的话window.opener.document.getElementById('id').value;
要是iframe的话就用
window.parent.document.getElementById('id').value;

------解决方案--------------------
楼主可以参考下

http://blog.csdn.net/wangfan1207/article/details/7878459

貌似在IE下可以,chrome下失效,firefox没有测试。
------解决方案--------------------
window.parent这个好像是用在iframe中的,子窗口访问父窗口的。
如果是open或者showModalDialog开来的子窗口的话,就不是这样传值了。
------解决方案--------------------
window.open用window.opener;其他的一般用window.parent