谁能教我如何在HTML中创建一个聊天框?我使用jquery和Ajax创建动态网页。我尝试使用输入文本框,但我不知道如何让另一个聊天框在其中发布双方的会话。
最小二乘法
发布于 2011-01-04 03:52:53
只要有一个由你的javascript动态更新的DIV即可。
你也可以通过google找到关于这方面的大量教程。像这样的here
特别是,JQuery的这一小部分将为您提供一个思路:
function LoadNewMessages() {
// Loads new messages from retrieve_new.php file into new_posts div
$('#new_posts').load("retrieve_new.php");
// Determines whether or not there is a new message by searching new_posts div
if (document.getElementById('new_posts').innerHTML != '') {
// If nothing exists it won't do anything but if there is it will post this:
$('#chatbox').prepend("
"+document.getElementById('new_posts').innerHTML+"
");
// This makes it fade in. Not necessary but cool.
$('#new_message').fadeIn(1000);
// Empties the div for future posts.
$('#actions').html("");
}
}
// Refreshes and checks for new messages.
setInterval("LoadNewMessages();", 1000);https://stackoverflow.com/questions/4587776
复制相似问题