我有一个场景需要读取html页面的源代码并将其保存为字符串。我需要在tinyMCE中检索此页面源代码。当我将tinyMCE的setcontent设置为此字符串时,会得到\r\n。我希望它们以换行符的形式出现而不是字符串。我尝试用
替换字符串,但效果不佳。请问是否有人能够帮助解决?
tinyMCE.init({
// General options
mode: "specific_textareas",
theme: "advanced",
width: "100%",
plugins: "pagebreak,paste,fullscreen,visualchars",
entity_encoding: "raw",
remove_linebreaks: false,
init_instance_callback: "customTinyMceInit",
// Theme options
theme_advanced_buttons1: "code,|,bold,italic,underline,|,sub,sup,|,charmap,|,fullscreen,|,bullist,numlist,|,pasteword",
theme_advanced_buttons2: "",
theme_advanced_buttons3: "",
theme_advanced_buttons4: "",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_statusbar_location: "bottom",
valid_elements: "i,sub,sup",
invalid_elements: "p, script",
editor_deselector: "mceOthers"
});
function customTinyMceInit(inst) {
if (window.opener != null && !window.opener.closed) {
var parent = $(window.opener.document).contents();
var Id = queryString["Id"];
var Result = [];
$.ajax({
type: "POST",
url: "/Modules/Management/OnlineTemplateCreation.aspx/GetTemplateByContentId",
data: "{'Id':"+Id+"}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
Result.push(data.d);
alert(Result[0]);
tinyMCE.getInstanceById("RichTextBox").setContent(Result[0]);
}
});