How did Facebook implement the chat sidebar?
Asked Answered
R

3

7

I'm trying to understand how Facebook implements the chat sidebar. It seems to stay there even as I change pages. For example, if I select some text inside the sidebar, then click to go to another Facebook page, the text remains selected. It's as if it was a separate frame, but when I look at the code, it's not.

Reiterate answered 11/1, 2012 at 13:4 Comment(0)
S
3

There is a container DOM element called "fb_content", its content is replaced through straight-forward AJAX or more technically XMLHttpRequest. (Although when for example you enter an app, the entire page is refreshed.) To update the address bar they use the JavaScript History API.

Stimulus answered 11/1, 2012 at 13:24 Comment(0)
H
4

All requests are made trough AJAX calls. Only "content" container is replaced when needed.

You don't actually "go" to another page. Just the "content" div gets updated.

Hudak answered 11/1, 2012 at 13:19 Comment(0)
S
3

There is a container DOM element called "fb_content", its content is replaced through straight-forward AJAX or more technically XMLHttpRequest. (Although when for example you enter an app, the entire page is refreshed.) To update the address bar they use the JavaScript History API.

Stimulus answered 11/1, 2012 at 13:24 Comment(0)
P
0

In addition to what Zeno and lericson said (fb_content gets updated via ajax), the address bar also gets updated while maintaining the history (if you press back/forward).

Pegboard answered 10/3, 2014 at 6:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.