Javascript 替换textarea脚本中的文本+;RTE
我有一个javascript代码,可以替换在文本区域中编写的一些单词。如果我写“狗”这个词,它会把它改成“猫”这个词Javascript 替换textarea脚本中的文本+;RTE,javascript,replace,textarea,rte,Javascript,Replace,Textarea,Rte,我有一个javascript代码,可以替换在文本区域中编写的一些单词。如果我写“狗”这个词,它会把它改成“猫”这个词 函数changeText(){ dt=document.getElementsByTagName(“textarea”)[0]; dt.value=dt.value.replace(/dog/g,“cat”); dt.value=dt.value.replace(/blue/g,“red”); dt.value=dt.value.replace(/good/g,“bad”);
函数changeText(){
dt=document.getElementsByTagName(“textarea”)[0];
dt.value=dt.value.replace(/dog/g,“cat”);
dt.value=dt.value.replace(/blue/g,“red”);
dt.value=dt.value.replace(/good/g,“bad”);
}
这个脚本有两个问题,我不知道如何解决
var fileContent = '';
var client = new XMLHttpRequest(); // we create a request
client.open('GET', '/foo.txt'); // foo.txt is the name of the file
client.onreadystatechange = function() {
fileContent = client.responseText;
alert("Hooray! My file was loaded, this is its content: " + fileContent );
}
client.send(); // and we send a request
var fileContent = '';
var client = new XMLHttpRequest(); // we create a request
client.open('GET', '/foo.txt'); // foo.txt is the name of the file
client.onreadystatechange = function() {
fileContent = client.responseText;
alert("Hooray! My file was loaded, this is its content: " + fileContent );
}
client.send(); // and we send a request
var nicInstance = nicEditors.findEditor('idOfYourTextarea');
var notes = nicInstance.getContent(); // voila - your content