JavaScript 3.1.6 Web Include

Copy and Paste this code to the bottom of your <BODY> tag. This gives you access to PUBNUB.publish() and PUBNUB.subscribe() functions and more!

<div pub-key="" sub-key="" ssl="off" origin="pubsub.pubnub.com" id="pubnub"></div>
<script src="http://cdn.pubnub.com/pubnub-3.1.min.js"></script>
<script>(function(){

    // LISTEN FOR MESSAGES
    PUBNUB.subscribe({
        channel    : "hello_world",      // CONNECT TO THIS CHANNEL.

        restore    : false,              // STAY CONNECTED, EVEN WHEN BROWSER IS CLOSED
                                         // OR WHEN PAGE CHANGES.

        callback   : function(message) { // RECEIVED A MESSAGE.
            alert(message)
        },

        disconnect : function() {        // LOST CONNECTION.
            alert(
                "Connection Lost." +
                "Will auto-reconnect when Online."
            )
        },

        reconnect  : function() {        // CONNECTION RESTORED.
            alert("And we're Back!")
        },

        connect    : function() {        // CONNECTION ESTABLISHED.

            PUBNUB.publish({             // SEND A MESSAGE.
                channel : "hello_world",
                message : "Hi from PubNub."
            })

        }
    })

})();</script>

*** This JavaScript include file is unique to your account. It includes keys which link to your account.

*** PubNub JavaScript Push API does not depend on other libraries.

*** Do not download and host this file yourself. Otherwise updates will not reach your website.

JavaScript Push API Reference