Các ứng dụng chat thực hiện các chức năng cơ bản về bài viết và lấy tin nhắn. Mỗi người dùng có thể chọn một biệt hiệu và gửi một tin nhắn. Các cửa sổ có chứa tất cả các tin nhắn đăng được cập nhật bằng cách lấy các thông điệp không đồng bộ từ máy chủ. | AJAX Chat 12. After having talked about it it is time to see it in action. Let s see how the chat window looks in the beginning. Load http local host ajax chat with a web browser. Figure The Chat Window You can observe the default color of your messages is black RGB code 000000 . In Figure we can also see a default random name Guest91. When initially loading the chat window all previously posted messages are displayed. You can change your messages color by simply clicking on the palette image on the desired color. What just happened Technically the application is split in two smaller applications that build our final solution The chat application Choosing a color application The chat application implements the basic functions of posting and retrieving messages. Each user can choose a nickname and post a message. The chat window containing all the posted messages is updated by retrieving the messages asynchronously from the server. We use a palette containing the entire spectrum of colors to allow the user pick a color for the text he or she writes. When clicking on the palette the mouse coordinates are sent to the server which obtains the color code. 160 Chapter 5 If you analyze the code for a bit the details will become clear. Let s have a look at it starting with the index. html file. The only part that is really interesting in this script is a scroll region that can be implemented in DHTML. A little piece of information regarding scrolling can be found at http dhtml scroll . Basically the idea for having a part of the page with a scrollbar next to it is to have two layers one inside another. In our example the div scroll and its inner layers do the trick. The outer layer is scroll. It has a fixed wi dth and hei ght and the most useful property of it is overflow. Generally the content of a block box is confined to the content edges of the box. In certain cases a box may overflow meaning its content lies partly or entirely .