In a previous thread that I linked to, I detailed my situation in depth. To save space, I won't repeat all the details here.
However, I have encountered an issue with the answer to my question.
function form_submit (event) {
var form, bClickNotSubmit;
if (event && event.type == 'click') {
bClickNotSubmit = true;
form = document.getElementById ('quick_reply_form');
}
else {
bClickNotSubmit = false;
form = event ? event.target : this;
}
var arTextareas = form.getElementsByTagName ('textarea');
for (var i = arTextareas.length - 1; i >= 0; i--) {
var elmTextarea = arTextareas[i];
elmTextarea.value = "[font=Tahoma][color=white]" + elmTextarea.value + "[/color][/font]";
}
if ( ! bClickNotSubmit ) {
form._submit();
}
}
window.addEventListener ('submit', form_submit, true);
document.getElementById ('quick_reply_submit').addEventListener ('click', form_submit, true);
HTMLFormElement.prototype._submit = HTMLFormElement.prototype.submit;
HTMLFormElement.prototype.submit = form_submit;
While this code works perfectly fine in Firefox, it seems there is a glitch in Chrome. The added text appears at the beginning and end of the input field as expected, but it does not happen quickly enough. This results in the form being submitted before the modifications are fully applied.
Does anyone know how to fix this timing issue?