xampp - Javascript not working when accessing from remote computer -


i accessed client page using link

http://xx.xx.xx.xx/project/client.php  

.it has few lines of javascript , html not working @ . when access client page using link

http://localhost/project/client.php  

, works. know should change in javascript code dont know . please tell me . here client code :

<html> <head>   <style>  #chatlog {width:440px; height:200px; border:1px solid;overflow:auto;}   #userslog {width:440px; height:200px; border:1px solid;overflow:auto;} #msg {width:330px; height:100px;} </style>  <script>    function initialize(){   var host = "ws://localhost:12345/project/server3z.php";   try{     socket = new websocket(host);     chatlog('websocket - status '+socket.readystate);     socket.onopen    = function(event){chatlog("websocket status "+this.readystate); };     socket.onmessage = function(event){ chatlog(event.data); };     socket.onclose   = function(){ chatlog("websocket  status "+this.readystate); }; socket.onerror    = function(event){chatlog("error :"+event.data); };   }   catch(err){ chatlog(err); }  }  function send() {   var chat;    chat= document.getelementbyid("msg").value;   if(!chat){ alert("message can not empty"); return; }    try{ socket.send(chat); chatlog('sent: '+chat); } catch(err){ log(err); }   document.getelementbyid("msg").value = ""; } function quit(){   chatlog("closed!");   socket.close();   chatlog("websocket  status "+socket.readystate);  }    function chatlog(msg) { var match=msg.match(/10101010101010/g); if(match) { var msg=msg.split("10101010101010"); document.getelementbyid("userslog").innerhtml+="<br>"+msg[0]; } else { document.getelementbyid("chatlog").innerhtml+="<br>"+msg; } }  function onkey(event){ if(event.keycode==13){ send(); } }  </script>  </head> <body onload="initialize()"> <center> <div id="chatlog"></div> <input id="msg" type="textbox" onkeypress="onkey(event)"/> <button onclick="send()">send</button> <button onclick="quit()">stop</button> <div id="userslog"></div> </center> </body> </html> 

you using websocket sure browser in other pc it's supports html5 , websocket?

websocket introduced early


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -