בקשר לשאלה הראשונה:
קוד:
xxx.value.replace(REPLACEWHAT,REPLACE WITH);
בקשר לשניה:
קצת ארוך מקווה שתבין הכל:
קוד:
function is_ie() {
if (navigator.appName == "Microsoft Internet Explorer")
return true;
else
return false;
}
function text2color(text,c) {
txtElement = document.forms.myform.text;
if (is_ie()) {
txtElement.focus();
docSelection = document.selection;
txtSelection = docSelection.createRange();
if (txtSelection.text != "") {
txtSelection.text = '<font color="'+c+'">'+txtSelection.text+'</font>';
} else {
txtElement.value = '<font color="'+c+'">'+txtElement.value+'</font>';
}
} else {
txtElement.focus();
docSelection = txtElement.value.substring(txtElement.selectionStart, txtElement.selectionEnd);
if (docSelection != "") {
var newValue = "";
newValue += txtElement.value.substring(0, txtElement.selectionStart);
newValue += '<font color="'+c+'">'+docSelection+'</font>';
newValue += txtElement.value.substring(txtElement.selectionEnd, txtElement.value.length);
txtElement.value = newValue;
} else {
txtElement.value = '<font color="'+c+'">'+txtElement.value+'</font>';
}
}
}