子窗口关闭时的回调函数调用 [英] Callback function call when child window is close

查看:350
本文介绍了子窗口关闭时的回调函数调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

单击按钮时,我打开了子窗口。在此窗口中,我将一些数据保存到数据库中。
我想在子窗口关闭时调用另一个java脚本函数。

I have open child window when click on button.In this window I have save some data into database. I want to call another java script function when child window is close.

我已经尝试过这个在javascript 解决方案中将回调函数设置为新窗口,但它无效。

I have already tried this Set a callback function to a new window in javascript solution but it is not working.

那么请告诉我如何调用回调函数?

So please tell me how to call callback function ?

我成功保存后还从子窗口设置了一个隐藏字段。我已经尝试在更新之前提醒这个隐藏值但是它的警报。

I have also set one hidden field from child window after successfully save.I have try to alert this hidden value but its alert before updating.

function open_child()
{
    $("#child_succ").val(0);
    alert($("#child_succ").val());
    window.open("child.php","Ratting","width=550,height=300,left=150,top=200,toolbar=1,status=1");
    alert($("child_succ").val());
}

回调功能

function test()
{
    alert("called from child window");
}


推荐答案

您可以调用父函数从子窗口这样:

You may call a parent function from child window this way:

window.opener.your_function()

在父窗口中调用子函数:

To call a child function in parent window:

var w = window.open(somelocation,''); //has a function on `window` called "test"
w.test();

如果这些提示有任何帮助,您可以向我们展示您如何使用回调方法。

If any of this tips help you, you may show us how the callback approach was used by you.

希望这可以帮到你。

问候!

这篇关于子窗口关闭时的回调函数调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆