当窗口关闭时触发是否有事件? [英] Is there an event when that triggers when the window is closing??

查看:56
本文介绍了当窗口关闭时触发是否有事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




当窗口关闭时触发事件是否有事件....我是

谈论用户点击十字架的时间在窗口右上角

窗口!!!



Is there an event when that triggers when the window is closing.... I am
talking about when the user clicks on the cross on the right top corner of
the window!!!

推荐答案



" Tom Szabo < to*@intersoft.net.au> escreveu na mensagem

新闻:41 ****** @ dnews.tpgi.com.au ...

"Tom Szabo" <to*@intersoft.net.au> escreveu na mensagem
news:41******@dnews.tpgi.com.au...


有没有当窗口关闭时触发的事件....我正在谈论当用户点击窗口右上角的十字架时!!!
Onunload体元素上面给出了一个例子:
< body OnunLoad =" javascript :window.alert(''感谢您访问我们的网站'')">


Is there an event when that triggers when the window is closing.... I am
talking about when the user clicks on the cross on the right top corner of
the window!!!
The Onunload body element an example is given above:
<body OnunLoad="javascript:window.alert(''Thanks for visiting our site'')">



" Oscar Monteiro" < ** @ hotmail.com制造>在留言新闻中写道:< 41 *********************** @ news.telepac.pt> ...。
"Oscar Monteiro" <of**@hotmail.com> wrote in message news:<41***********************@news.telepac.pt>.. .
" ; Tom Szabo < to*@intersoft.net.au> escreveu na mensagem
新闻:41 ****** @ dnews.tpgi.com.au ...
"Tom Szabo" <to*@intersoft.net.au> escreveu na mensagem
news:41******@dnews.tpgi.com.au...


触发时是否有事件当窗口关闭时......我正在谈论当用户点击窗口右上角的十字架时!!!
Onunload体元素的一个例子是如上所述:
< body OnunLoad =" javascript :window.alert(''感谢您访问我们的网站'')>


Is there an event when that triggers when the window is closing.... I am
talking about when the user clicks on the cross on the right top corner of
the window!!!
The Onunload body element an example is given above:
<body OnunLoad="javascript:window.alert(''Thanks for visiting our site'')">




没有''Onunload body element'' - onunload是一个事件

处理程序属性(窗口)。您感兴趣的事件的名称

in是unload,它调用[window。] onunload处理程序。

MSIE / FireFox 0.9+也支持window.onbeforeunload ,允许

在运行脚本方面有更多余地,包括完全取消关闭




大多数提出此问题的人都是有兴趣在实际尝试关闭窗口(或导航到另一个

网站)和在他们自己的网站内进行简单的页面更改之间进行区分

。由于两个

事件处理程序都被这些中的任何一个调用 -

当前文档的卸载是触发器 - 各种曲折方法都有

已被配置为捕获一个实际的关闭事件,从弹出''间谍''

窗口观察动作,标记内部链接陷阱

他们的使用情况......你说出来的。我对其中大部分的经验并没有令人鼓舞。这是来自glenngv的新方法

codingforums.com:


< html>

< head>

< title>在IE中检测关闭窗口< / title>

< script language =" javascript">

function doUnload ()

{

if((window.event.clientX< 0)&&(window.event.clientY< 0))

{

提醒(窗口关闭...);

}

}

< / script>

< / head>

< body onunload =" doUnload()">

< h3>在IE中检测关闭窗口< / h3>

执行以下3种方式并查看差异:< br>

1.尝试刷新页面。< br>

2.尝试在地址栏中键入任何URL。< br>

3.尝试通过单击X关闭此窗口这个窗口的按钮。

< / body>

< / html>


抓住mousecli ck的位置。 IE只,但很容易修改。什么

你到底需要做什么?



No such thing as an ''Onunload body element'' - onunload is an event
handler property (of window). The name of the event you''re interested
in is unload, which invokes the [window.]onunload handler.
MSIE/FireFox 0.9+ also support window.onbeforeunload, which allows
more leeway in running script, including cancelling the close
entirely.

Most people who ask about this are interested in discriminating
between an actual attempt to close the window (or navigate to another
site) and a simple change of page within their own site. Since the two
event handlers are called by any of these - the unloading of the
current document is the trigger - all sorts of tortuous methods have
been configured to catch an actual close event, from popping up ''spy''
windows to observe the action, to flagging internal links to trap
their usage to...you name it. My experience with most of these has not
been encouraging. Here''s a novel approach from glenngv of
codingforums.com:

<html>
<head>
<title>Detecting Closing of Window in IE</title>
<script language="javascript">
function doUnload()
{
if ((window.event.clientX < 0) && (window.event.clientY < 0))
{
alert("The window is closed...");
}
}
</script>
</head>
<body onunload="doUnload()">
<h3>Detecting Closing of Window in IE</h3>
Do the 3 ways below and see the difference:<br>
1. Try to refresh the page.<br>
2. Try to type any URL in the address bar.<br>
3. Try to close this window by clicking X button of this window.
</body>
</html>

Catches the mouseclick position. IE only, but easily modifiable. What
exactly did you need to do?


RobB" < FE ****** @ hotmail.com>在消息中写道

news:ab ************************** @ posting.google.c om ...
RobB" <fe******@hotmail.com> wrote in message
news:ab**************************@posting.google.c om...
" Oscar Monteiro" < ** @ hotmail.com制造>在消息中写道
news:< 41 *********************** @ news.telepac.pt> ...。
"Oscar Monteiro" <of**@hotmail.com> wrote in message news:<41***********************@news.telepac.pt>.. .
" Tom Szabo" < to*@intersoft.net.au> escreveu na mensagem
新闻:41 ****** @ dnews.tpgi.com.au ...
"Tom Szabo" <to*@intersoft.net.au> escreveu na mensagem
news:41******@dnews.tpgi.com.au...


触发时是否有事件当窗口关闭时....我在讨论当用户点击窗口右上角
角落的十字架时,我正在讨论这个问题。
Onunload体元素的一个例子是如上所述:
< body OnunLoad =" javascript :window.alert(''感谢您访问我们的


Is there an event when that triggers when the window is closing.... I am talking about when the user clicks on the cross on the right top corner of the window!!!
The Onunload body element an example is given above:
<body OnunLoad="javascript:window.alert(''Thanks for visiting our



site'')">
没有''Onunload body element'' - onunload是一个事件
处理程序属性(窗口)。你感兴趣的事件的名称是卸载,它调用[window。] onunload处理程序。
MSIE / FireFox 0.9+也支持window.onbeforeunload,它允许
更多运行脚本的余地,包括完全取消关闭

大多数提出此问题的人都有兴趣区分实际关闭窗口的尝试(或导航到另一个窗口)
网站)和他们自己网站内的简单页面更改。由于两个
事件处理程序都被这些中的任何一个调用 -
当前文档的卸载是触发器 - 各种曲折的方法已被配置为捕获实际的关闭事件,从弹出''间谍''窗口来观察动作,标记内部链接以捕获它们的用法......你的名字。我对其中大部分的经验并没有令人鼓舞。这是来自
< html>
< head>
< title>检测关闭窗口IE< / title>
< script language =" javascript">
函数doUnload()
{
if((window.event.clientX< 0)& ;&(window.event.clientY< 0))
{
警告(窗口关闭...);
}
}
< / script>
< / head>
< body onunload =" doUnload()">
< h3>检测IE中关闭窗口< / h3>
请按以下3种方式查看差异:< br>
1.尝试刷新页面。< br>
2.尝试在地址中键入任何URL 3.单击此窗口的X按钮,尝试关闭此窗口。
< / body>
< / html>


你好Rob,


我想做的是:


如果是孩子的话用户使用x关闭窗口。在顶部

左角(这是过早考虑实际应用)我需要

来启用父窗口(开启者)上的数据控件!!


其次,如果父窗口以同样的方式关闭,我需要关闭孩子的
。 - >这是必要的,因为从孩子我可以禁用父母的所有

控件,而不是X,所以他们可以关闭窗口......


顺便拜托这些东西,我会很快尝试,


问候,


Tom


site'')">
No such thing as an ''Onunload body element'' - onunload is an event
handler property (of window). The name of the event you''re interested
in is unload, which invokes the [window.]onunload handler.
MSIE/FireFox 0.9+ also support window.onbeforeunload, which allows
more leeway in running script, including cancelling the close
entirely.

Most people who ask about this are interested in discriminating
between an actual attempt to close the window (or navigate to another
site) and a simple change of page within their own site. Since the two
event handlers are called by any of these - the unloading of the
current document is the trigger - all sorts of tortuous methods have
been configured to catch an actual close event, from popping up ''spy''
windows to observe the action, to flagging internal links to trap
their usage to...you name it. My experience with most of these has not
been encouraging. Here''s a novel approach from glenngv of
codingforums.com:

<html>
<head>
<title>Detecting Closing of Window in IE</title>
<script language="javascript">
function doUnload()
{
if ((window.event.clientX < 0) && (window.event.clientY < 0))
{
alert("The window is closed...");
}
}
</script>
</head>
<body onunload="doUnload()">
<h3>Detecting Closing of Window in IE</h3>
Do the 3 ways below and see the difference:<br>
1. Try to refresh the page.<br>
2. Try to type any URL in the address bar.<br>
3. Try to close this window by clicking X button of this window.
</body>
</html>
Hi Rob,

What I want to do is:

firstly if the child window is closed by the user using the "x" on the top
left corner (that is prematurely considering the actual application) I need
to enable the data controls on the parent window (opener)!!

secondly, if the parent window is closed in the same way, I need to close
the child. -> this is needed because from the child I can disable all the
controls on the parent, but not the "X", so they can close the window...

Thanks for the stuff by the way, I will try soon,

Regards,

Tom


Catches the mouseclick position. IE only, but easily modifiable. What
exactly did you need to do?



这篇关于当窗口关闭时触发是否有事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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