Hey, i just noticed something on facebook.com, facebook was in my other tab, and i was browsing on SO, after a while i switched back to facebook.com and it like fades in new news in the wall. How did they make a script that knows when you are active again without clicking anywhere it shall refresh new messages etc. ? Just like facebook chat also if you have it on another tab/window then you'll hear "blub" or Facebook: **NEW MESSAGE FROM: name. How does it do that?
Do it run a timeout checker each second, i dont think so ? , that would be really alot of traffic and server response time, if around 3-4-500 million users would do that each day.
Could someone provide example where to place ajax call if it the user has left the focus and its getting onfocus again, how to make a code that runs a ajax call there? jquer开发者_Python百科y?
Would this not work using the focus event on the window object? ie:
window.onfocus = refreshStuff;
where refreshStuff is your function for refreshing...err...stuff.
https://developer.mozilla.org/en/DOM/window
http://msdn.microsoft.com/en-us/library/ms536934(v=VS.85).aspx
Sorry - I would have added this to the comments, but I can't - possibly because I don't have enough reputation yet.
精彩评论