Skip to content

Commit 80672de

Browse files
committed
fixed Single Page Demo in Docs.
1 parent d1d33a5 commit 80672de

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ you access PubNub methods via ```p```'s instance methods:
7575

7676
```javascript
7777
p.publish({
78-
channel : "hello_world",
79-
message : "Hi."
80-
})
78+
channel : "hello_world",
79+
message : "Hi."
80+
})
8181
```
8282

8383
When working with any non-web JavaScript-based client (such as a mobile
@@ -144,26 +144,31 @@ JavaScript SDK using the **web** build. It's as easy as `copy/paste`.
144144
>**NOTE:** Copy and paste this example into a *blank* HTML file.
145145
146146
```html
147-
<div id=pubnub pub-key=demo sub-key=demo></div>
148147
<script src=http://cdn.pubnub.com/pubnub-3.5.1.min.js ></script>
149-
<script>
148+
<script>(function(){
150149
150+
// Init
151+
var pubnub = PUBNUB.init({
152+
publish_key : 'demo',
153+
subscribe_key : 'demo'
154+
})
155+
151156
// LISTEN
152-
PUBNUB.subscribe({
157+
pubnub.subscribe({
153158
channel : "hello_world",
154159
message : function(m){ alert(m) },
155160
connect : publish
156161
})
157162
158163
// SEND
159164
function publish() {
160-
PUBNUB.publish({
165+
pubnub.publish({
161166
channel : "hello_world",
162167
message : "Hi."
163168
})
164169
}
165170
166-
</script>
171+
})();</script>
167172
```
168173

169174
## ADVANCED SUBSCRIBE CONNECTIVITY OPTIONS/CALLBACKS

0 commit comments

Comments
 (0)