我试图在用户提交聊天时发出声音,也会在其他人的声音中听到。这里是我的代码:Javascript + Pubnub聊天室通知
Enter Chat and press enter
<div><input id=input placeholder=you-chat-here /></div>
<code>Chat Output</code>
<div id=box></div>
<div id=pubnub pub-key=demo sub-key=demo></div>
<script src=http://cdn.pubnub.com/pubnub-3.1.min.js></script>
<script>(function(){
var box = PUBNUB.$('box'), input = PUBNUB.$('input'), channel = 'chatlllll';
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({
playsound('http://www.aphpsite.comuv.com/sound/chat.wav')
channel : channel,
message : input.value,
x : (input.value='')
});
});
})();</script>
这就是我所拥有的。我无法添加声音。该脚本已损坏。所以这些都不起作用。我想如果有人能解决它。
谢谢。
非常感谢。 – Djmann1013 2012-07-18 13:47:39