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) {




    function ajaxLogout(){

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



		// Opera 8.0+, Firefox, Safari

		call_Logout = new XMLHttpRequest();                

	} catch (e){

		// Internet Explorer Browsers


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

		} catch (e) {


				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)




    }"GET", "index.php?r=room/Logout", true);





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

e.returnValue='any string';]

just under the the ajaxLogout() call