# Catching attempts to close the browser

**URL:** <https://forum.kirupa.com/t/catching-attempts-to-close-the-browser/237997>\
**Category:** web dev\
**Created:** [September 6, 2007, 5:08am UTC](https://forum.kirupa.com/t/catching-attempts-to-close-the-browser/237997 "2007-09-06T05:08:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthewjumps](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@matthewjumps](https://forum.kirupa.com/u/matthewjumps)\
**Post date:** [September 6, 2007, 5:08am UTC](https://forum.kirupa.com/t/catching-attempts-to-close-the-browser/237997/1 "2007-09-06T05:08:50Z")

</div>

[http://www.customink.com/lab/](http://www.customink.com/lab/) features an extensive javascript/ajax tshirt design utility, but one of the things im interested in is the function that is triggered when the user attempts to navigate away from/close the page if they have made any changes. an alert is displayed that warns the user that they will lose their edits, preventing the page from being closed.

how is this achieved? any ideas? im assuming its done using javascript? any help would be appreciated :azn:
