通过浏览器窗口的气泡事件 [英] Bubble events via browser windows

查看:131
本文介绍了通过浏览器窗口的气泡事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望你们能帮助我.
我熟悉从用户控件到控件所在页面(父级)的冒泡事件.

在这种情况下-我有一个页面可以使用:
打开一个新窗口 btnBeginSurvey.Attributes.Add("onclick", "SurveyPopUp=window.open(''survey.aspx'', ''SurveyPopUp''); SurveyPopUp.focus()")


用户完成调查后,我想关闭子窗口并将事件冒泡直到父浏览器窗口,告诉它刷新.

任何人都可以帮我吗?

非常感谢您的任何帮助!

谢谢,
Scott

Hi, hoping you guys can help me.
I''m familiar with bubbling events from a user control up to the page (parent) that the control resides on.

In this case - I have a page that opens a new window using :
btnBeginSurvey.Attributes.Add("onclick", "SurveyPopUp=window.open(''survey.aspx'', ''SurveyPopUp''); SurveyPopUp.focus()")


When the user finishes the survey, I want to close the child window and bubble an event up to the parent browser window telling it to refresh.

Can anyone please help me at all ?

Any help at all is gratefully received !

Thanks,
Scott

推荐答案

好吧,这不完全是冒泡",但这应该可以工作-在您的子窗口中,每当调查完成时,您都可以执行类似的操作:

Well, it''s not exactly "bubbling", but this should work - in your child window, whenever the survey is finished you can do something like:

<script type="text/javascript">
    function closeAndRefreshParent() {
        window.opener.location = window.opener.location;
    }
</script>
<input type="button" onclick="closeAndRefreshParent();" value="Close & Refresh" />



或者,您可以在父窗口中具有一个函数,并在需要时从弹出窗口中调用它:

在父窗口中:



Or you can have a function in the parent window, and call it from popup whenever you want:

In the parent window:

function doSomething() {
 ....
}



并从弹出窗口中调用它:



And call it from the popup:

window.opener.doSomething();


您也可以看一下这篇文章,几乎做了类似的事情:在子窗口关闭时通过AJAX(ASP.NET 2.0)对父页面进行部分更新-有条件 [ ^ ]
You can also look at this article, doing almost something similar: Partial update of parent page via AJAX (ASP.NET 2.0) on close of a child window - conditionally[^]


这篇关于通过浏览器窗口的气泡事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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