应用程序关闭时如何关闭JavaScript弹出窗口 [英] How to close a javascript popupwindow when application closes

查看:126
本文介绍了应用程序关闭时如何关闭JavaScript弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个Web应用程序.通过javascript,我已经从应用程序中打开了一个弹出窗口.关闭我的应用程序后,通过javascript方法打开的弹出窗口没有被关闭.
这是我的javascript

Hi all ,

I have a web application. In that through javascript I have opened a popup window from my application.Once I close my application, the popup window which is opened through javascript method is not getting closed.
This is my javascript

function show() {
                 myRef = window.open(''http://www.google.com, ''mywin'',
''left=20,top=20,width=700,height=600,toolbar=1,resizable=1'');
}



关闭应用程序后如何关闭此弹出窗口?

任何人都可以在这个问题上提供帮助吗?

预先感谢,

Naveen



How to close this popup when application is closed?

Can anyone help on this issue ?

Thanks in advance,

Naveen

推荐答案

检查关闭父窗口时打开的子窗口使用JavaScript [ ^ ]


嗨 纳文,

您可以使用维护列表中的所有窗口"来完成.

在主文档中脚本顶部的某个位置包含
行:
Hi Naveen,

You can do using maintain all window in list.

Somewhere at the top of your script in your main document you include a
line:
var children=Array();



现在,每当您要打开新的子窗口时,请确保使用类似于以下内容的行:



Now whenever you want to open a new child window make sure you use a line similar to:

children[children.length]= name of the window;



然后,您可以使用一个功能,例如:



You can then have one function such as:

function closeAllChildren()
{
   for(var n=0;n<children.length;n++)
   {
       children[n].close();
   }
   //Oh, and close self!
   window.close();
}



每个子文档只需要一个按钮即可调用此函数,如下所示.



Each child document just needs a button to call this function as follows.

<input type="button" onclick="window.opener.closeAllChildren()">




如有任何疑问,请让我知道.

请提供"投票":thumbsup:如果有帮助,请提供"接受答案",如果这是正确的答案.:rose:

谢谢,
Imdadhusen




Please do let me know, if you have any doubt.

Please provide "Vote":thumbsup: if this would be helpful, and make "Accept Answer" if this would be correct answer.:rose:

Thanks,
Imdadhusen


这篇关于应用程序关闭时如何关闭JavaScript弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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