Add files via upload
This commit is contained in:
parent
cf1dcfa825
commit
597595e797
1 changed files with 57 additions and 0 deletions
57
chatroom.HTML
Normal file
57
chatroom.HTML
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Chatroom</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
}
|
||||||
|
#chatbox {
|
||||||
|
width: 400px;
|
||||||
|
height: 300px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
padding: 10px;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
#message {
|
||||||
|
width: 100%;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
#send {
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="chatbox"></div>
|
||||||
|
<input type="text" id="message" placeholder="Type your message">
|
||||||
|
<button id="send">Send</button>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const chatbox = document.getElementById('chatbox');
|
||||||
|
const messageInput = document.getElementById('message');
|
||||||
|
const sendButton = document.getElementById('send');
|
||||||
|
|
||||||
|
sendButton.addEventListener('click', sendMessage);
|
||||||
|
|
||||||
|
function sendMessage() {
|
||||||
|
const message = messageInput.value;
|
||||||
|
if (message.trim() !== '') {
|
||||||
|
const messageElement = document.createElement('div');
|
||||||
|
messageElement.textContent = message;
|
||||||
|
chatbox.appendChild(messageElement);
|
||||||
|
chatbox.scrollTop = chatbox.scrollHeight; // Scroll to the bottom
|
||||||
|
messageInput.value = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
messageInput.addEventListener('keyup', function(event) {
|
||||||
|
if (event.key === 'Enter') {
|
||||||
|
sendMessage();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Add table
Reference in a new issue