betezek Posted July 12, 2012 Report Share Posted July 12, 2012 :unsure: Pessoal, tenho uma dúvida aqui, porque tentei de todas as maneiras colocar um som de chamada neste script e ele não toca o som.O som viria com a frase "Você recebeu uma nova mensagem" mas ele não interpreta. Talvez alguém saiba de um jeito de fazer isso sem abrir novo popup.Abraços a todos!}//atualiza texto do chatfunction trataDados(){ var info = ajax.responseText; if(info){ ExibirMsg(info); document.getElementById("texto").focus(); alert("Você recebeu uma nova mensagem!"); }O script inteiro é este:// JavaScript Document//dispara a função que lê o servidorwindow.onload = function(){ window.setInterval('ChecaMsg()', 3000);}//envia uma nova mensagemfunction EnviaMsg(msg){ ExibirMsg("<p><b>Você:</b> "+msg+"</p>"); var url="novaMsg2.php?msg="+encodeURIComponent(msg); document.getElementById("msg").value=''; requisicaoHTTP("GET",url,true);}//busca novas mensagensfunction ChecaMsg(){ requisicaoHTTP("GET","checaMsg2.php",true);}function TrataMsgExibir(msg){ msg=msg.replace(new RegExp(/[email protected]@/g),"<\\"); msg=msg.replace(new RegExp(/\\\\/g),"\\"); msg=msg.replace(new RegExp(/[email protected]@/g),"/"); msg=msg.replace(new RegExp(/''/g),"'"); msg=msg.replace(new RegExp(/[email protected]@/g),"\\"); return msg;}function TrataMsgEnviar(msg){ msg=msg.replace(new RegExp(/\\/g),"[email protected]@"); msg=msg.replace(new RegExp(/'/g),"''"); msg=msg.replace(new RegExp(/\//g),"[email protected]@"); EnviaMsg(msg);}function ExibirMsg(msg){ msg = TrataMsgExibir(msg); var saida = document.getElementById("texto"); var nova = document.createElement('div'); nova.innerHTML = msg; saida.appendChild(nova); saida.scrollTop = 100000; //rolagem automatica}function NovoAtendimento(){ var saida = document.getElementById("texto"); saida.innerHTML = ''; // limpa o texto do chat requisicaoHTTP("GET","excluirMsg.php",true);}//atualiza texto do chatfunction trataDados(){ var info = ajax.responseText; if(info){ ExibirMsg(info); document.getElementById("texto").focus(); alert("Você recebeu uma nova mensagem!"); }} Quote Link to comment Share on other sites More sharing options...
0 wrodrigounb Posted July 13, 2012 Report Share Posted July 13, 2012 Aqui é Java, não JavaScript.ÁREA ERRADA! Quote Link to comment Share on other sites More sharing options...
0 bareta Posted August 6, 2012 Report Share Posted August 6, 2012 movendo Quote Link to comment Share on other sites More sharing options...
Question
betezek
:unsure: Pessoal, tenho uma dúvida aqui, porque tentei de todas as maneiras colocar um som de chamada neste script e ele não toca o som.
O som viria com a frase "Você recebeu uma nova mensagem" mas ele não interpreta. Talvez alguém saiba de um jeito de fazer isso sem abrir novo popup.
Abraços a todos!
}
//atualiza texto do chat
function trataDados(){
var info = ajax.responseText;
if(info){
ExibirMsg(info);
document.getElementById("texto").focus();
alert("Você recebeu uma nova mensagem!");
}
O script inteiro é este:
// JavaScript Document
//dispara a função que lê o servidor
window.onload = function(){
window.setInterval('ChecaMsg()', 3000);
}
//envia uma nova mensagem
function EnviaMsg(msg){
ExibirMsg("<p><b>Você:</b> "+msg+"</p>");
var url="novaMsg2.php?msg="+encodeURIComponent(msg);
document.getElementById("msg").value='';
requisicaoHTTP("GET",url,true);
}
//busca novas mensagens
function ChecaMsg(){
requisicaoHTTP("GET","checaMsg2.php",true);
}
function TrataMsgExibir(msg){
msg=msg.replace(new RegExp(/[email protected]@/g),"<\\");
msg=msg.replace(new RegExp(/\\\\/g),"\\");
msg=msg.replace(new RegExp(/[email protected]@/g),"/");
msg=msg.replace(new RegExp(/''/g),"'");
msg=msg.replace(new RegExp(/[email protected]@/g),"\\");
return msg;
}
function TrataMsgEnviar(msg){
msg=msg.replace(new RegExp(/\\/g),"[email protected]@");
msg=msg.replace(new RegExp(/'/g),"''");
msg=msg.replace(new RegExp(/\//g),"[email protected]@");
EnviaMsg(msg);
}
function ExibirMsg(msg){
msg = TrataMsgExibir(msg);
var saida = document.getElementById("texto");
var nova = document.createElement('div');
nova.innerHTML = msg;
saida.appendChild(nova);
saida.scrollTop = 100000; //rolagem automatica
}
function NovoAtendimento(){
var saida = document.getElementById("texto");
saida.innerHTML = ''; // limpa o texto do chat
requisicaoHTTP("GET","excluirMsg.php",true);
}
//atualiza texto do chat
function trataDados(){
var info = ajax.responseText;
if(info){
ExibirMsg(info);
document.getElementById("texto").focus();
alert("Você recebeu uma nova mensagem!");
}
}
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.