Lesson 3: Get a live chat on your page!|
Lesson 3: Get a live chat on your page!
Learn to make a live chat room without Java. All code is available.
View the demo to see the result.
I've built a chat room using the dictionary object in IIS,
but I needed a PWS chat room for a LAN-party. It's based on VBScript
cause I really hate those JAVA chat progs. This one outputs only
pure HTML, and work on any browser that supports frames, cookies and
meta refresh (I guess that means something like Netscape 3.0 and newer
and IE 3.0 and newer). I must warn you that the code is a bit sloppy.
I was pretty low on sleep when I trough this together. It works,
but I really would like somebody to stress test it a bit.
The concept is this. You click a link and this window
You are prompted for a nickname, which
is then stored in a cookie.
The user is then sent to this window with 2 frames:
Frame1: Shows the chat content. The content is stored in 10 global variables
and the page refreshes (with a META REFRESH tag) every 5th second.
Frame2: Has a little form to add a sentence to the conversation.
When used it tags the sentence with your username (from the cookie),
and sends it to the variables. The last entered sentence is removed,
and the new one is added.
The code is pretty straight forward, and shouldn't need more
Default.asp The first page (see the first screenshot)
Display.asp Frame1 in the last screenshot. Displays the conversation.
Message.asp Frame2 in the last screenshot.
Logoff.asp Called when you click exit. Removes cookie, and sends a bye message.
I've added messages that are displayed on entry
of new person in the chat room, and on exit.
The next step would be adding more lines (say 15.) and
maybe some more rooms. And maybe a list showing the people that are logged in to the room.
A last comment:
It's rated medium because you have to modify the Global.asa
This is a cool and ez script, use and enjoy...