Non-refresh Chat room technology Implementation method (ASP-related)

Source: Internet
Author: User
Tags clear screen key
Chat Room | refresh | No refresh no refresh chat Room technology Realization method
  
I. Unifying nouns
Text box: frames page showing chat content
Input box: Enter the frame page of the chat information
Refresh box: A frames page that gets the latest chat information from the refresh, and the page doesn't show up directly

Second, how to achieve
Without refreshing, you want to add new chat information constantly after the current text box chat content.
The implementation is "add new information" instead of "refresh".

Third, technical points
Implement key code to use for flash-free chat rooms like chat.163.com:
1. Self Refresh:
<meta http-equiv= "Refresh" content= "2" >
2. Write code to HTML file:
<script>
Top.frametext.document.write ("text");
</script>

Iv. examples
1.frame.asp page. The simplest consists of three frames pages
text Box Frametext.htm;name=frametext
Input box frameinput.asp;
Refresh Box framerefresh.asp;

2. Text Box frametext.htm content:
The simplest text content. Slightly

3. Input Box frameinput.asp content:
Slightly

4. Refresh box framefresh.asp content (key)
......
<%
' Here's the code to get the latest chat information
' Latest information saved in array Arrrecord ()
' Outnum parameter record if a new chat record appears
%>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<meta http-equiv= "Refresh" content= "2" ><!--timed Refresh to get the latest information-->
.....
<%
If Outnum>0 then ' for the user, if there is new information, then output new information, otherwise not
Output
Response.Write "<script language=" "JavaScript" ">"
For i = 1 to Outnum
Response.Write "Top.frametext.document.write" ("" "& Arrrecord (i) &" ")
;"
Next
Response.Write "</script>"
End If
%>
.....

V. Related issues
1. A problem with the self refresh is the focus location problem (i.e., the automatic scrolling problem). Users in the text
This box to see is the first time to enter the chatroom to see the content of the location, will not automatically scroll to the new information
Position, you must scroll the scroll bar.
In chat.163.com, it is achieved by selecting the "Automatic Scrolling" method by the user. It's actually a choice.
Automatic scrolling ", the program will enable control text box scrolling a JS program, the key part is:
function ScrollWindow ()
{
.....
This.scroll (0, 65000); Scroll the text box to the specified location. Here designates (0,65000)
, is pointing to the bottom left corner position, because the screen height is only 600 less, so in a user chat process
, it is almost never possible to reach the position of (0,65000). This ensures that the screen is always rolled to the bottom.

SetTimeout (' ScrollWindow (); ', 200); Cycle. Otherwise it's useless to scroll only once.
}

2. Clear screen. If you do not clear the screen, always open the Chat window, text box text content will be endless increase.
Clear screen can be achieved by reload the text box page.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.