# \[FMX\] kind of "onClose" function

**URL:** https://forum.kirupa.com/t/fmx-kind-of-onclose-function/15627
**Category:** Uncategorized
**Created:** [March 16, 2003, 7:09am UTC](https://forum.kirupa.com/t/fmx-kind-of-onclose-function/15627 "2003-03-16T07:09:15Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Voglio](https://avatars.discourse-cdn.com/v4/letter/v/a88e57/32.png) [@Voglio](https://forum.kirupa.com/u/Voglio)
#### Post date: [March 16, 2003, 7:09am UTC](https://forum.kirupa.com/t/fmx-kind-of-onclose-function/15627/1 "2003-03-16T07:09:15Z")

</div>

Here is another one for you guys…

Do you know if there is a trigger that can be called when the user close an swf (for example, if he close its browser while a swf was playing) ?

thanks for your help.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 16, 2003, 7:21am UTC](https://forum.kirupa.com/t/fmx-kind-of-onclose-function/15627/2 "2003-03-16T07:21:38Z")

</div>

Not that I know of. Sorry. In Javascript there is, but if you ask me, the person closed the window for a reason, nothing should happen after that. Just my 2 cents (even though you didn’t ask, sorry).

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 16, 2003, 7:54am UTC](https://forum.kirupa.com/t/fmx-kind-of-onclose-function/15627/3 "2003-03-16T07:54:41Z")

</div>

That’s not for launching an advertising popup but for sending data to php (like “your last session last ‘x’ minutes”).

🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 16, 2003, 8:21am UTC](https://forum.kirupa.com/t/fmx-kind-of-onclose-function/15627/4 "2003-03-16T08:21:58Z")

</div>

Ok, well that is fair. I know this method works in Later versions of Netscape (not sure when it started) and in IE, but the onUnload command sounds like what you need and is done with JS.

```php
<SCRIPT LANGUAGE="JavaScript">
<!--
function closedWin(){
alert("window closed");
}
-->
</SCRIPT>

```

Insert that between your \<HEAD\>\</HEAD\> tags.

Now add to your body tag an onUnload…

\<BODY onUnload=“closedWin();”\>

This will launch and alert when the window is closed, but instead of launching an alert, if you can, have it send whatever info you need. I don’t know much PHP, so I can’t help you with that.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 16, 2003, 7:00pm UTC](https://forum.kirupa.com/t/fmx-kind-of-onclose-function/15627/5 "2003-03-16T19:00:04Z")

</div>

hey thanks ! I’m gonna give it a try.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 16, 2003, 7:01pm UTC](https://forum.kirupa.com/t/fmx-kind-of-onclose-function/15627/6 "2003-03-16T19:01:57Z")

</div>

No problem, I hope it works out :beam:
