<script language="JavaScript"> window.onbeforeunload = confirmExit; function confirmExit() { $.post("test.PHP"); } </script>