2

I wan to make some fixed divs on bottom persistent without reloading them if user is on my site. It is like Facebook chat, user can be all over the site but chat is allways visible?

This queston is because I have created chat with NodeJS and when page is refreshed connection is destroyed and again created, so I want to make this connection persistent even during the reloading the page.

I know possible soluton that make every request Ajax call, but... this is unusable....

3
  • Well, if AJAXing everything else on your page isn’t an option – then there’s always the good old popup window, that’s not connected to any reloading going on in it’s parent window … and frankly, not much else.
    – CBroe
    Aug 30, 2012 at 19:39
  • The short answer is honestly the one you gave. As for it being "unusable," frameworks like Backbone and Knockout, among others, can help. Alternatives are currently limited to iframes and WebSockets. Aug 30, 2012 at 19:44
  • Actually I am using SockJS to connect on Node. Ajax is not good because it is to much work to be done for every link :(
    – theZiki
    Aug 31, 2012 at 9:16

1 Answer 1

1

You can try localstorage. Data will persist on reload.

Use that with json.stringify and json.parse to make it work.

Unfortunately some older browsers still in use won't like that. I think all new browser versions can use localstorage. If you're not concerned about old browsers that's fine too.

There are localstorage shims, but that depends on how much work you're willing to put in to your project.

You can use localstorage to just store the html too if you like. I prefer dom element updates using json values myself.

Visit browser version market share and you'll see quite a few of the older versions are out of usage. Though like with any tech usage stats you should take them with a grain of salt.

Edit Whoops! You said fixed divs without reloading them. I don't think that's possible if they are a chat. Unless I don't understand the question. Post some code if you can.

2
  • how did facebook achive this, that chat window is always open?
    – theZiki
    Nov 30, 2012 at 14:05
  • 1
    I couldn't say for sure. On inspection of that element it looks like it has regular html for the chat interface. It's probably using php sessions with dom updates. Because facebook is so ubiquitous and they had the chat before localstorage existed they probably use a comet mechanism with php sessions and dom updates. Looks like they use aria too which is an accessible standards api for dom manipulations. They are at least using some kind of dom update. I invite any facebook developers to contribute some knowledge because I can only guess what they use. Dec 1, 2012 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.