window.onbeforeunload support in firefox/opera

Has anyone come across this before? What I’m trying to do is, if a user closes their browser I’m calling an ajax function to log them out and delete them from the db. The below function works in both chrome and safari, but not firefox or opera. Is there anything I can do to remedy this?


<script type="text/javascript">

    

  window.onbeforeunload = function (e) {

  var e = e || window.event;


  //IE & Firefox

  if (e) {

    ajaxLogout();

  }


  };   

    function ajaxLogout(){

	var call_Logout;  // The variable that makes Ajax possible!

	

	try{

		// Opera 8.0+, Firefox, Safari

		call_Logout = new XMLHttpRequest();                

	} catch (e){

		// Internet Explorer Browsers

		try{

			call_Logout = new ActiveXObject("Msxml2.XMLHTTP");                        

		} catch (e) {

			try{

				call_Logout = new ActiveXObject("Microsoft.XMLHTTP");                               

			} catch (e){

				// Something went wrong

				alert("Your browser doesn't seem to support ajax!");

				return false;

			}

		}

	}

	// Create a function that will receive data sent from the server

	call_Logout.onreadystatechange = function(){

                

		if(call_Logout.readyState == 4)

                {

                    //alert(mod_votingStatusRequest.responseText);                                                            

                }                

    }

 

	call_Logout.open("GET", "index.php?r=room/Logout", true);

	call_Logout.send(null); 

        

}

</script>

Never mind, seems to be working now that I added this line.


e.returnValue='any string';]

just under the the ajaxLogout() call