Problem: An error message alert occurs in IE 6
Help: I need someone who can fix a code so that the error won't show up in IE.
Note: I've tested it under Firefox and Opera and it works very well.
Here's the code:
CODE
/**
* ezShout - AJAX/PHP ShoutBox
* by Albert Villaroman
*
* For help and tutorials on usage, please refer to manual
*
* Note: Due to JS lack of standard OOP conventions, treat "Shoutbox Class" comment as a class constructor,
* and all states and methods encapsulated in it are properties of the class
**/
//-----------------------------------------------------------------------------------
// Shoutbox Class
//-----------------------------------------------------------------------------------
/**
* Pre: Sates
*/
var RecieverAj; //AJAX object that makes requests to server for shouts
var SenderAj; //AJAX object that sends shout out to server and store it in database
var refresh_sb; //JS timer that will refresh list of shouts every 5 seconds
var lastShout_sb=""; //Global variable that stores last shout which is to be compared to continuosly refreshed list of shout outs - Purpose: to prevent repetitive refresh of the list
/**
* I. Obtain latest shouts from database every x seconds
*/
//request the server for latest shouts
function loadShouts_sb() {
RecieverAj = new ajaxConn();
RecieverAj.serverscript = "ezShout/includes/procedures/fetchShouts.php";
RecieverAj.setValues("rand=" + Math.random());
RecieverAj.connect("displayShouts_sb", "GET");
}
window.onload = loadShouts_sb();
//display list of shouts when response from server is recieved
function displayShouts_sb (response) {
switch (response) {
case lastShout_sb: break;
default: alert("hi"); document.getElementById("shoutcontents_sb").innerHTML = response; lastShout_sb = response; setRefreshTime_sb(); break;
}
}
//set a Timer that runs loadShouts_sb in 5 seconds
function setRefreshTime_sb() {
refresh_sb = setTimeout('refreshShouts_sb()', 5000);
}
//request again after 5 seconds
function refreshShouts_sb () {
RecieverAj.connect("displayShouts_sb", "GET");
clearTimeout(refresh_sb);
refresh_sb = setTimeout('refreshShouts_sb()',5000);
}
/**
* II. Send a shout out to the server and store it in database
*/
//onSubmit, send `name` and `message` input to server via `SenderAj`
function sendShout_sb () {
var name = document.getElementById("shouter_sb").value;
var message = document.getElementById("shout_sb").value;
SenderAj = new ajaxConn();
SenderAj.serverscript = "ezShout/includes/procedures/sendShout.php";
SenderAj.setValues("name=" + name + ",message=" + message + ",rand=" + Math.random());
SenderAj.connect("isShoutSuccessful_sb", "POST");
}
//check if shout out sent is stored in the database; successful
function isShoutSuccessful_sb (response) {
switch (response) {
case "true": alert("Your shout has been sent."); break;
case "false": alert("Unsuccessful post. Please report this."); break;
}
document.getElementById("shout_sb").value = "your message";
document.getElementById("shout_sb").style.background = "#E9E9E9";
}
//clear value of selected object
function clearValueOf_sb(object) {
object.value = "";
object.style.background = "#FFFFFF";
}
//-----------------------------------------------------------------------------------
// End of Shoutbox Class
//-----------------------------------------------------------------------------------
* ezShout - AJAX/PHP ShoutBox
* by Albert Villaroman
*
* For help and tutorials on usage, please refer to manual
*
* Note: Due to JS lack of standard OOP conventions, treat "Shoutbox Class" comment as a class constructor,
* and all states and methods encapsulated in it are properties of the class
**/
//-----------------------------------------------------------------------------------
// Shoutbox Class
//-----------------------------------------------------------------------------------
/**
* Pre: Sates
*/
var RecieverAj; //AJAX object that makes requests to server for shouts
var SenderAj; //AJAX object that sends shout out to server and store it in database
var refresh_sb; //JS timer that will refresh list of shouts every 5 seconds
var lastShout_sb=""; //Global variable that stores last shout which is to be compared to continuosly refreshed list of shout outs - Purpose: to prevent repetitive refresh of the list
/**
* I. Obtain latest shouts from database every x seconds
*/
//request the server for latest shouts
function loadShouts_sb() {
RecieverAj = new ajaxConn();
RecieverAj.serverscript = "ezShout/includes/procedures/fetchShouts.php";
RecieverAj.setValues("rand=" + Math.random());
RecieverAj.connect("displayShouts_sb", "GET");
}
window.onload = loadShouts_sb();
//display list of shouts when response from server is recieved
function displayShouts_sb (response) {
switch (response) {
case lastShout_sb: break;
default: alert("hi"); document.getElementById("shoutcontents_sb").innerHTML = response; lastShout_sb = response; setRefreshTime_sb(); break;
}
}
//set a Timer that runs loadShouts_sb in 5 seconds
function setRefreshTime_sb() {
refresh_sb = setTimeout('refreshShouts_sb()', 5000);
}
//request again after 5 seconds
function refreshShouts_sb () {
RecieverAj.connect("displayShouts_sb", "GET");
clearTimeout(refresh_sb);
refresh_sb = setTimeout('refreshShouts_sb()',5000);
}
/**
* II. Send a shout out to the server and store it in database
*/
//onSubmit, send `name` and `message` input to server via `SenderAj`
function sendShout_sb () {
var name = document.getElementById("shouter_sb").value;
var message = document.getElementById("shout_sb").value;
SenderAj = new ajaxConn();
SenderAj.serverscript = "ezShout/includes/procedures/sendShout.php";
SenderAj.setValues("name=" + name + ",message=" + message + ",rand=" + Math.random());
SenderAj.connect("isShoutSuccessful_sb", "POST");
}
//check if shout out sent is stored in the database; successful
function isShoutSuccessful_sb (response) {
switch (response) {
case "true": alert("Your shout has been sent."); break;
case "false": alert("Unsuccessful post. Please report this."); break;
}
document.getElementById("shout_sb").value = "your message";
document.getElementById("shout_sb").style.background = "#E9E9E9";
}
//clear value of selected object
function clearValueOf_sb(object) {
object.value = "";
object.style.background = "#FFFFFF";
}
//-----------------------------------------------------------------------------------
// End of Shoutbox Class
//-----------------------------------------------------------------------------------
You can view the application here: click here

