简体   繁体   English

在关闭弹出窗口之前将值传递给Java Bean

[英]Pass values to Java Bean before closing pop-up window

I an trying to pass values from the pop-up window to Java Bean and close the window. 我试图将值从弹出窗口传递到Java Bean并关闭该窗口。 What happens is either values are passed JBeans but the window remains open, either I close the pop-up window and values are not passed. 发生的情况是要么传递了JBeans值,但是窗口保持打开状态,或者我关闭了弹出窗口并且没有传递值。 Can anyone help me make this work. 谁能帮我做这个工作。 Parent and child windows use the same JBean 父窗口和子窗口使用相同的JBean

Parent code: 父代码:

<script type="text/javascript">

child_open = function () {
        var m = document.getElementById('clickForm');
        m.style.display = 'block';
        m.onclick = refocus;
        m.data = data;
        m.submit();     
    };
</script>
...
<FORM ID="clickForm" METHOD=POST  action="child.jsp" target="TheWindow"> 
...
<br> <INPUT TYPE=SUBMIT VALUE="Submit" onclick="child_open()"> <br>
</FORM>

Child Code (Pop-up Window) 子代码(弹出窗口)

<script type="text/javascript">
closeChild = function () 
{
   window.opener.location.reload();
   // if I close it, then data is no passed to beans
   // if I leave it open, then data is passed 
   window.close();
}
</script>
...
<FORM ID="clickForm" METHOD="POST">
    <br>
    <DIV ALIGN="left">
    <INPUT TYPE="submit" VALUE="Done!" onclick="closeChild()"  formtarget="_parent"/>
    </DIV>
    ...
</FORM>

Try looking at local storage . 尝试查看本地存储 Presuming the parent and child are from the same domain, they can see the common data store. 假设父级和子级来自同一域,则他们可以看到公共数据存储。 The child captures what you need and persists to the local storage. 子级将捕获您所需的内容并保留到本地存储中。 The parent would then read storage to get the value. 然后,父级将读取存储以获取该值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM