homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Gold Sponsor 2015!
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Clicking on Back button terminates Ajax web IM

10+ Year Member

Msg#: 5621 posted 3:21 am on Jun 27, 2006 (gmt 0)

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?



10+ Year Member

Msg#: 5621 posted 7:47 pm on Jun 28, 2006 (gmt 0)

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.");}


WebmasterWorld Senior Member 10+ Year Member

Msg#: 5621 posted 4:37 pm on Jun 30, 2006 (gmt 0)

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?

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved