Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook chatbox doesn't reload between pages

I observed this feature in Facebook, that when you have a chat box opened at the bottom right, and you go to another page, say, your friend's profile, or some photo collection page within Facebook, the chat box doesn't reload, it remains where it is (as if in a separate layer on top of the background page).

So naturally, I thought that Facebook isn't reloading the page per se, it is using history.pushstate and related functions to load the content asynchronously, and changing the URL dynamically (Firebug confirmed it, if you click on one of your friend's name and is taken to your friend's profile page, it is actually a GET request that is getting fired). So since there isn't exactly any page loading, the chatbox can just lay idle, as it is.

However, pushstate isn't supported by IE prior to version 10. Still, it works just fine in IE9 as well. So can anyone tell me how are they doing it? Are they using the history API at all, or something different?

like image 758
SexyBeast Avatar asked Mar 24 '13 09:03

SexyBeast


People also ask

Why is my Facebook Chat not working?

If it still doesn't work, reasons why include: The person you're trying to message deactivated or deleted their account. You've blocked the person you're trying to message or they've blocked you. You're trying to respond to a group conversation that the other members of the conversation have already left.


1 Answers

That's a great question with a simply answer. I'm not sure about Facebook, but this should help you - History.js

History.js gracefully supports the HTML5 History/State APIs (pushState, replaceState, onPopState) in all browsers. Including continued support for data, titles, replaceState. Supports jQuery, MooTools and Prototype. For HTML5 browsers this means that you can modify the URL directly, without needing to use hashes anymore. For HTML4 browsers it will revert back to using the old onhashchange functionality.

like image 147
Alexis B. Avatar answered Sep 17 '22 11:09

Alexis B.