views:

116

answers:

3

Hello All,

Do you guys have any idea of how to implement an automatic top bar like that of Stackoverflow which appears when you look at a question.

I wonder how do they do it because there is no event triggered when you are at a page which has already been loaded. Also there is no page refresh. After being at questions/asnwer page; you see a message something like "new answers available, load them?"

Here is the screenshot of that:

alt text

+3  A: 

That sort of thing is done by using JavaScript to query the server via mechanisms like the XmlHttpRequest (this is commonly called "Ajax" -- Asynchronous Javascript And XML, but you don't have to use XML and frequently JSON is used instead), and then modifying the document via DOM (Document Object Model) methods. This sort of thing is frequently made easier with JavaScript toolkits/libraries like jQuery, Prototype, YUI, Dojo, and Google's new "Closure Library".

T.J. Crowder
+1  A: 

Check out these jQuery plugins that notify or "growl" at you.

fudgey
A: 

The term you are looking for is "comet" programming, or "server push". There are several ways to do it, and different browsers cope with it in different ways. So use a library.

wisty