views:

92

answers:

1

hi .. This is my chats' sign out function. It works perfectly when I open the chat on a page alone.e.g. www.abc.com/chatbox/index.htm But when its with other elements in the same page using iFrame it will not work.e.g.www.abc.com/chat&paintIframe.htm

This is my code

<script type="text/javascript">
function singout(){

data="user=" + "" +"&oper=signout"
Ajax_Send("POST","chatbox/users.php",data,checkSignOut);
alert("Singout");
return false;     
}
</script>

and here I call it

<iframe height="300" width="600" frameborder="0" src="chatbox/index.htm"     onbeforeunload="singout()"></iframe> 

Any help is appreciated ..

A: 

I'm gonna go out on a limb here and say that there isn't an issue with the function, but instead with what you expect onbeforeunload to do. I believe you expect that if the browser is closed, or the user navigates away from the page it will execute the event onbeforeunload, which is unfortunately not the case, or at least it will not be consistent.

The best method of ensuring that the user is logged out when they no longer have the browser open is instead to use ajax to make a call to the server every few seconds. If the call is made then successfully refresh the session, if it is not successful then you have nothing to worry about really because the session will timeout on its own after a certain amount of time.

evolve
can you tell me how to call sever ?sorry ,i am new to learning ajax .
Nina