2 Replies Latest reply on Mar 25, 2008 5:14 AM by Kerdudou Ronan

    call method on unload body

    Stijn Cremers Novice

      hi, i want to call a java method when somebody closes the browser or goes to another site.

      So, i want to call an event on the unload event of the body.
      But i can't hang an a4j:support tag on a non-jsf tag like body.

      How can i do this?

      Greetz

        • 1. Re: call method on unload body
          Kerdudou Ronan Apprentice

          you can try something like :


          ...
          <a4j:jsFunction name="myunload" action="..." />
          ...


          but it's more complicated to detect if the user is closing the browser or going to another site...

          for exemple :
          test=true;



          good luck...

          • 2. Re: call method on unload body
            Kerdudou Ronan Apprentice

            (sorry i forgot the "code" tag...)

            you can try something like :

            <body onunload="myunload();">
            ...
            <a4j:jsFunction name="myunload" action="..." />
            ...
            </body>


            but it's more complicated to detect if the user is closing the browser or going to another site...

            for exemple :
            <script>test=true;</script>
            <body onbeforeunload="if (test) myunload();">
            <form onsubmit="test=false;">


            good luck...