ok, I know that i can not detect browser exit via PHP, however i can do this via javascript. What i need to do is on exit, with javascript, i need to call a PHP script.

Not sure if this is even possible, but i thought i would throw it out there, any suggestions or theories are welcome.

thanks

    Hi,

    You can use onUnload in the <body> tag:

    <head>
     <script language="JavaScript">
     <!--
      function BrowserClosed()
      {
       window.open("http://URL_TO_PHP_SCRIPT");
      }
     //-->
     </script>
    </head>
    
    <body onUnload="BrowserClosed()">
    ...

    The PHP script may print <body onLoad="self.close()"> to close the window after all work had been done.

    Leif

      Originally posted by leifr
      Hi,

      You can use onUnload in the <body> tag:

      <head>
       <script language="JavaScript">
       <!--
        function BrowserClosed()
        {
         window.open("http://URL_TO_PHP_SCRIPT");
        }
       //-->
       </script>
      </head>
      
      <body onUnload="BrowserClosed()">
      ...

      The PHP script may print <body onLoad="self.close()"> to close the window after all work had been done.

      Leif [/B]

      Yeah but then it will prompt "The script that is currently running is trying to close this window, continue? Yes/No"...

        Wow, simple and great, thanks... I appreciate it...

        Aeiri -
        because the window is opend by javascript, its initialized by the javascript code it will close nicely. If the user had opened the window and it tried to close itself you would get the YES/NO prompt...

          That's right, man it's been so long since I've used JS...

            Write a Reply...