Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Clicking on Back button terminates Ajax web IM



3:21 am on Jun 27, 2006 (gmt 0)

10+ Year Member

I am building a web based (ajax) IM application that connects web visitors with webmasters called SNIMMER. The problem that we have encountered is that during an IM session if a user clicks on the browser "Back" button the session terminates.

I imagine this is standard javascript behavior - clicking on "Back" button resets existing javascript state and breaks the IM session.

Even preventing the "Back" click with a javascript pop-up does not work. While the user receives a js alert and has a choice to remain on the previous page - it still re-sets the javascript state and the IM session is lost. The same problem also arises when a user wants to closing the browser. We can generate a pop up, but cannot preserve the existing session.

Does anyone have any suggestions on how to tackle this? Is there a way to deal with this in javascript or flash?


7:47 pm on Jun 28, 2006 (gmt 0)

10+ Year Member

I found a solution (sadly without help of anyone on this forum).

window.onbeforeunload = function()
window.event.returnValue = "Your current chat session will terminate.";
//for Firefox

//window.onbeforeunload = function() {return("Your current chat session will terminate.");}


4:37 pm on Jun 30, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Maybe you could try storing the session in a cookie and then check for cookie-stored sessions and resurrect them when the previous page has loaded?

Featured Threads

Hot Threads This Week

Hot Threads This Month