document.getElementById("Message").innerHTML=document.getElementById("Message").innerHTML.replace("'","%%");
The above statement replaces only the first occurrence of the single quote. Could it be because that I do a submit right after that, and that javascript doesn't wait for the previous statement to be completed before moving on to the next one?