A McGraw Hill Book Plug-in PHP: 100 Power Solutions
By Robin Nixon (McGraw Hill 2010, ISBN 978-0071666596)

Home | About | Buy It | Download | Contact

Select Chapter: 1  2  3  4  5  6  7  8  9 10 11 12

Chapter 8: Plug-in 55 - View Chat

This plug-in is surprisingly small considering the power it packs, providing a continuously open connection to a chat server using just HTML, so that new messages appear as posted, without having to refresh the page. With some nifty JavaScript it also auto scrolls the page when new messages display at the page bottom, and it can distinguish between a private and a public message, displaying each to the correct people.

The Figure shows half a dozen users chatting as viewed from the user fredsmith's perspective. You can see all the public messages in regular typeface, and the private ones from and to fredsmith, shown in italic font, and prefaced by the string (PM to username).