How to make a chat room when the screen does not flash?

Source: Internet
Author: User
Tags client
Chat Room | Recently, there are a lot of people to ask in the development of chat room program when the screen is always refreshing, what to do?
When editing a chat room program, there are two ways to upload the server data to the browser. One is when there is information on the server side, push the information to the client, this way makes the load of the server heavier, the other is in the client with the Refresh command, most of the chat room in this way, so that we see the screen in the browser is constantly refreshing, very affected browsing, This is even more serious when the internet is slow.
Is there any way to solve the problem? The answer is yes. Let me introduce a way to solve this problem with javacript. First of all, we divided the Web page into three frames (the eagle only wants to use the simplest example to illustrate the principle, if you want to build more complex chat room, can be divided according to the specific circumstances. )。 The above frame is: main.htm, this frame is used to display the content of chatting; The following frame is: bottom.htm, used to enter chat content. Add a hidden frame: list.asp, the role of this frame is to make the input words can be displayed in the main.htm frame.
Frame.htm---chat room frame
<title>asp Cool Chat Room </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">

<frameset rows= "1,403,92" cols= "*" >
<frame src= "list.asp" name= "List" >
<frame src= "main.htm" name= "Main1" >
<frame src= "Bottom.htm" >
</frameset>
<noframes><body bgcolor= "#FFFFFF" >

</body></noframes>
----------------------------------
Main.htm

<title> Chat content display area </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">


<body bgcolor= "#FFFFFF" >

</body>
---------------------------------
Bottom.htm
<title> Chat Content Entry Area </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">

<body bgcolor= "#FFFFFF" >
<form name= "Form1" method= "POST"
action= "list.asp" target= "List" >
<div align= "center" >
<input type= "text" name= "comment" >
<input type= "Submit" name= "submit" value= "Write and read" >
</div>
</form>
</body>

----------------------------------------------
List.asp

<cript language= "Javacript" >
function Scrollon () {
Top.main1.scroll (0, 65000);
}
Top.main1.document.write (' <=request ("comment ') > ')
Top.main1.document.write (' <br> ')
</cript>

With the above method you can see that when you enter the chat content, in the chat room display area, you can see the contents of a line down to write, without the screen constantly refreshing situation. Come down and change the list.asp, I believe I can get the chat content from the database or from the Application object. It's just possible that list.asp needs to be refreshed, but for someone who chats in a chat room, the chat content is moved down one line.
Believe that in this way you can make a chat room that is not on the refresh screen.



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.