当我关闭窗户时做一个动作 [英] Doing an action when I close a window

查看:90
本文介绍了当我关闭窗户时做一个动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在设计一个应用程序,但我想知道我应该使用哪个事件,以便在我关闭窗口时执行一个操作.

我尝试使用window.close,但是当我加载/转到网站时它会执行操作,而当我想要关闭它时则不执行操作,这就是我想要的.

Hello, I''m designing an app but I want to know what event I should use for that an action will be done when I''ll close the window.

I''ve tried with window.close but it does the action when I load/go to the website and no when i want to close it, that is what i want that it does.

推荐答案

此链接将解释它,包括一个示例:

http://msdn.microsoft.com/en-us/library/ms536907.aspx [ ^ ]

祝你好运!
This link will explain it including an example:

http://msdn.microsoft.com/en-us/library/ms536907.aspx[^]

Good luck!


我的问题已解决将行分配为函数(JAVASCRIPT).
问题出在 ASPX页面中,并且是通过这种方法,当我加载/打开网站时发生了操作,而当我关闭网站时没有发生,但是添加了一个功能,我没有问题(例如在此块以及您给我的链接中):
My problem was solved assigning the lines like a function (JAVASCRIPT).
The problem was in an ASPX page, and it was that with this method, the action ocurred when i loaded/opened the website and no when i closed it, but adding a function, i haven''t problems (like in this block and the links that you has given me):
<pre>function closeIt() {<br />
            alert(''HI'');<br />
        }<br />
        window.onbeforeunload = closeIt;</pre><br />


而且没有这样(像这样我有问题):


and no like this (like this i had the problem):

window.onbeforeunload = alert(''Bye, bye'');


非常感谢您的帮助
问候


Thanks very much for your help
Regards


这篇关于当我关闭窗户时做一个动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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