One To One Messaging On WebSite
For Beginners and Professionals |
If you want to integrate one to one messaging for your website Simple Copy below Code and Paste in Any Where In Your HTML Page.
Testing : Open your website on more than two computers and start messaging.
Chat Output
<div id=box></div>
<script src=http://cdn.pubnub.com/pubnub.min.js></script>
<script>(function(){
var pubnub = PUBNUB.init({publish_key:'demo',subscribe_key:'demo',ssl:true});
var box = PUBNUB.$('box'), input = PUBNUB.$('input'), channel = 'chat';
pubnub.subscribe({
channel : channel,
callback : function(text) { box.innerHTML = (''+text).replace( /[<>]/g, '' ) + '<br>' + box.innerHTML }
});
PUBNUB.bind( 'keyup', input, function(e) {
(e.keyCode || e.charCode) === 13 && pubnub.publish({
channel : channel, message : input.value, x : (input.value='')
})
} )
})()</script>
Comments
Post a Comment