PHP AJAX CHAT, Bug fixes - including weird mozilla bug
Hello all. When I released PHP AJAX chat I knew that there was a problem with a few of the build of Firefox that didn’t like having SetTimeouts() outside of functions and requestobjects opening without full parameters. Well I have now fixed that and here is the patch. To install the patch do the following.
- Open up index.php oh php ajax chat archive
- find where this line is <script type=”text/javascript”> in mine it’s around line 33 and also find the end </script> which is around line 99.
- Hilight this area and replace it with the following code
function sndReq(doit) {
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject(”Msxml2.XMLHTTP”);
} catch (e) {
try {
xmlhttp = new ActiveXObject(”Microsoft.XMLHTTP”);
} catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != ‘undefined’) {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
httpr = xmlhttp;
if(doit){
chatsend = document.getElementById(”textbox”).value;
guyname = document.getElementById(”guyname”).value;
parameters = “nick=”+encodeURI(guyname)+”&textbox=”+encodeURI(chatsend);
httpr.onreadystatechange = handleResponse;
httpr.open(”POST”, “<?php echo $url;?>rpc.php”,true);
httpr.setRequestHeader(”Content-type”, “application/x-www-form-urlencoded”);
httpr.setRequestHeader(”Content-length”, parameters.length);
httpr.send(parameters);
document.getElementById(’textbox’).value = ”;
}else{
httpr.onreadystatechange = handleResponse;
httpr.open(”GET”,”<?php echo $url;?>rpc.php”,true);
httpr.send(null);
}
setTimeout(”sndReq(false)”,2000);
}
function handleResponse() {
if(httpr && httpr.readyState == 4){
var response = httpr.responseText;
document.getElementById(”chatbox”).innerHTML = response;
}
}
function formsubmit(e){
characterCode = null;
if(e && e.which){ //if which property of event object is supported (NN4)
e = e
characterCode = e.which //character code is contained in NN4’s which property
}
else{
e = event
characterCode = e.keyCode //character code is contained in IE’s keyCode property
}
if(characterCode == 13){
sndReq(true);
}
}
sndReq(false);
That’s it, also don’t forget to check out some of additional spam-protection patches
This is for original release of PHP AJAX CHAT
La viva revolution
No Comments yet »
RSS feed for comments on this post. TrackBack URI
Leave a comment
You must be logged in to post a comment.















