![](/img/trans.png)
[英]How to save and load content from html WYSIWYG editor in angular
[英]how to load content of a file to third part editor ex:(Wysiwyg editor)
我在我的Web应用程序中使用第三方WYSIWYG编辑器。 我想从文件加载内容。 如何加载内容? (javascript或React js)
var filecontent;
function selection(){
var filevalue=document.getElementById('files').value;
if(filevalue=="A"){
fetchDetailsA();
}
}
function fetchDetailsA() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var myObj = JSON.parse(this.responseText);
filecontent = this.responseText;
document.getElementById('NicEdit').innerHTML = filecontent;
document.myForm.NicEdit.value += "Hello";
alert(document.myForm.NicEdit.value)
}
};
xhttp.open("GET", "Textfiles/Sample1.json", true);
xhttp.send();
}
<form name="myForm">
<textarea id="NicEdit" cols="80" rows="5"></textarea>
</form>
您可以使用javascript中引入的fetch api来简化这一过程。
fetch('Textfiles/Sample1.json')
.then(response => response.text())
.then(text => {
document.getElementById('NicEdit').innerHTML = text;
document.myForm.NicEdit.value += "Hello";
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.