Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5947183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:55:42+00:00 2026-05-22T16:55:42+00:00

I am trying to implement a chat. I want to display the messages in

  • 0

I am trying to implement a chat. I want to display the messages in a div. My model looks like:

<div id="chatcontentcontainer">
   <div id="messageid">
       <div class="sender">sender name</div>
       <div class="messagebody">message text</div>
   </div>
   .....
   .....
</div>

and my javascript looks like:

var messages = responseXML.getElementsByTagName('ChatMessage');
var chatContainer = document.getElementById('chatcontentcontainer');
for (var i = 0; i < messages.length; i++)
{
    var msg = messages[i];
    var x = document.createElement('div');
    x.id = msg.children[0].textContent;
    x.innerHTML = msg.children[1].textContent;
    chatContainer.appendChild(x);
    _lastMessageId = x.id;
}

This fills the div with messages without the sender info. For beginning there are just messages.
How can I change this to check if a message was already displayed? Do you have any other suggestion for showing messages … I am interesting in performance because this will be refresh every 5 second.

Is there any other way of selecting msg.children[0] something like msg.children[‘Id’] without impacting performances?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:55:43+00:00Added an answer on May 22, 2026 at 4:55 pm

    Each div that you add to the list needs to be annotated with information that exists in the data. For example, you could give the divs an id of child_id_{x} if each msg has an id.

    Then, you could change your code to have an added check based on the id to make sure that element does not exist.

    Make sense?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement a browser based chat system with jQuery. I want
I am trying to implement a HTTP based chat here. All the chat messages
I'm trying to implement a very basic chat/echo web page. When the client visits
Trying to implement google C2DM service. registrationIntent.putExtra(app, PendingIntent.getBroadcast(context,0,new Intent(), 0)); registrationIntent.putExtra(sender,example@gmail.com); context.startService(registrationIntent); Almost every
Trying to implement 3-layer (not: tier, I just want to separate my project logically,
I am trying to implement simple chat application using flex. In it all my
I'm trying to implement a Chat Room for a forum of mine. I built
After painstakingly trying to implement TCP file transfer in my conference chat application using
I'm trying to implement a chat client using JavaScript. The client is constructed using
I'm trying to implement Simple chat using Servlet 3.0 and Comet pattern based on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.