我正在使用javascript获取 fckeditor 的值,以在对话框中显示为预览。现在我希望它显示html标签,就像我输入它们,但它显示我这个
<p><div>test</div></p>
即<div>test</div>
我使用以下代码
function test() {
var oEditor = FCKeditorAPI.GetInstance('FCKeditor1');
var pageValue = oEditor.GetHTML(true);
alert(pageValue);
}
我尝试更改
等设置FCKConfig.HtmlEncodeOutput = false;
FCKConfig.ProcessHTMLEntities = true;
FCKConfig.FormatSource = false;
没有运气。我现在对这个问题感到有点沮丧。 有谁知道为什么?
答案 0 :(得分:1)
为什么不使用DOM?
function unescapeHTML(html) {
var htmlNode = document.createElement("div");
htmlNode.innerHTML = html;
if(htmlNode.innerText)
return htmlNode.innerText; // IE
return htmlNode.textContent; // FF
}
(source)
答案 1 :(得分:-1)
@Pointy是的,我做到了。解决了这个问题。
.replace(/\</g, '<').replace(/\>/g, '>')