Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <meta charset="utf-8">
- <body>
- <input type="text" id="chat_input" placeholder="Your message..."></input>
- <input type="text" id="nick" placeholder="Enter your nick"></input>
- <span id="msg_holder"></span>
- <style>
- div {
- background: #004040;
- font-family: "Enigmatic Unicode";
- font-size: 15px;
- color: #fff;
- padding: 10px;
- border-radius: 10px;
- width: auto;
- height: 10px;
- margin: 3px;
- }
- input {
- background: #103535;
- color: #FFFFFF;
- padding: 5px;
- width: 350px;
- height: 18px;
- border-radius: 10px;
- transition: 250ms;
- }
- input:hover {
- color: #AA8080;
- background: #009999;
- }
- p {
- font-family: Arial;
- font-color: #000000;
- transition: 1s;
- font-size: 18px;
- display: inline-block;
- }
- a {
- font-family: Tahoma;
- font-color: #000025;
- transition: 1s;
- font-size: 12px;
- display: inline;
- margin-right: 20px;
- }
- </style>
- <script>
- document.getElementById("chat_input").addEventListener("keypress", function( e ) {
- var key = e.which || e.keyCode;
- if ( key == 13 && this.value.length > 0 && this.value != ' ' && this.value != '' ) {
- place_message( this )
- }
- })
- function place_message( v ) {
- var MSG_FRAME = document.createElement('div')
- var holder = document.createElement('span')
- var nick = document.createElement('p')
- var txt = document.createElement('a')
- txt.innerHTML = v.value
- v.value = ''
- nick.innerHTML = document.getElementById("nick").value + ": "
- MSG_FRAME.appendChild(holder)
- holder.appendChild(nick)
- holder.appendChild(txt)
- document.getElementById("msg_holder").appendChild(MSG_FRAME)
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement