-Log in
-Register (free)

-RSS Feeds
-New MyDesk Module
-Update to Profile

Alternate color for RS looping with For Next
Northwind / ASP - Nested select
ASP SQL Injection

 Lesson 3: Get a live chat on your page!
Lesson 3: Get a live chat on your page!

Author: Alexander Haneng
Difficulty: Medium
Requires: ASP
Demo: demo
Download: Lesson3.zip
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 code:
The concept is this. You click a link and this window pops up:

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 explanation.

File list:
  • 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.
    Download code

    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 file. This is a cool and ez script, use and enjoy...

    2: A banner ad rotator
    4: Add an ASP guestbook!
  • | Info |
    © Copyright 1997-2016 Alexander Haneng