“Chatbox HTML” Code-Antworten

HTML -Chatbox

<h1>Chat-box (With HTML and JAVASCRIPT)</h1>
<title>User chat</title>
<div><input id=input placeholder="Press Enter to Send" /></div><br><br>
Chat Output
<div id=box></div>
<script src=https://cdn.pubnub.com/sdk/javascript/pubnub.4.28.2.min.js></script>
<script> (function() {
        var pubnub = new PubNub({
            publishKey: 'demo',
            subscribeKey: 'demo'
        });
        function $(id) {
            return document.getElementById(id);
        }
        var box = $('box'),
            input = $('input'),
            channel = '10chat-demo';
        pubnub.addListener({
            message: function(obj) {
                box.innerHTML = ('' + obj.message).replace(/[<>]/g, '') + '<br>' + box.innerHTML
            }
        });
        pubnub.subscribe({
            channels: [channel]
        });
        input.addEventListener('keyup', function(e) {
            if ((e.keyCode || e.charCode) === 13) {
                pubnub.publish({
                    channel: channel,
                    message: input.value,
                    x: (input.value = '')
                });
            }
        });
    })();
</script>
Thomas coder

Chatbox HTML

with chat box
Hilarious Hedgehog

Ähnliche Antworten wie “Chatbox HTML”

Fragen ähnlich wie “Chatbox HTML”

Weitere verwandte Antworten zu “Chatbox HTML” auf HTML

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen