Brushless Chat Room Technology Implementation Method
1. Unified term
Text box: Display the framework page of the chat content
Enter box: Framework page of entering chat information
Refreshing box: self -refreshing the framework page for obtaining the latest chat information, this page does not display directly
How to achieve
To achieve no refresh, it is to continue to add new chat information behind the current text box chat content.
The way to implement is "adding new information", not "re -refresh".
Third, technical points
Realize the key code that is used like Chat.163.com to refresh the chat room:
1. Self -refresh:
<meta http-equiv = refresh content = 2>
2. Write code to html file:
<script>
top.frametext.document.write (text);
</script>
Fourth, example
1.Frame.asp page. The simplest contains three framework 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. Enter frame Frameinput.asp content:
slightly
4. Framefresh.asp content (key)
... ...
<%
'Use code here to obtain the latest chat information
'The latest information is stored in the array Arrrecord ()
'Outnum parameter records have new chat records appear
%>
<html>
<head>
<meta http-equiv = content-type content = text/html; charset = gb2312>
<meta http-equiv = refresh content = 2> <!-regular refresh to get the latest information->
...
<%
If Outnum> 0 THEN 'For users, if there is new information, you will output new information, otherwise
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
%>
...
5. Related issues
1. One problem that refreshes the focus is the focus positioning problem (that is, the problem of automatic screen). User in text
What I saw in this box is the location of the content seen for the first time to enter the Chatroom, and it will not automatically roll to the new information
The position must be rolled.
In Chat.163.com, it is implemented by clicking the "automatic screen" method by users. In fact, choose "
"Auto -screen", the program will enable a JS program that controls the schedule of the control text box. The key part is:
Function scrollwindow ()
{{
...
this.Scroll (0, 65000); // Put the text box scroll to the specified location. Select here (0,65000)
It is pointing to the position in the lower left corner. Because the screen height is less than 600, it is in the process of chatting in a user.
In the middle, it is almost impossible to reach (0,65000). This ensures that the screen will always roll to the bottom forever.
settimeout ('scrollwindow ();', 200); // cycle. Otherwise, it is useless to roll once
}
2. Clear screen. If the screen is not clear, the chat window has been opened, and the text box text will never increase.
Clear screens can be implemented by the RELOAD text box page.
Collect the most practical webpage special effect code!