views:

51

answers:

2

hi. I am getting the value of a fckeditor with javascript to show in a dialog as preview. Now I want it to show the html tags like I input them but instead it shows me this

<p>&lt;div&gt;test&lt;/div&gt;</p>

that is <div>test</div>

I use this following code

function test() {
        var oEditor = FCKeditorAPI.GetInstance('FCKeditor1');
        var pageValue = oEditor.GetHTML(true);

        alert(pageValue);            
    }

I have tried to change settings like

FCKConfig.HtmlEncodeOutput = false;
FCKConfig.ProcessHTMLEntities = true;
FCKConfig.FormatSource = false;

No luck with that. I am getting a little frustrated with this problem now. Anybody got a idea why?

A: 

@Pointy yes I did. Solved it tho.

.replace(/\&lt;/g, '<').replace(/\&gt;/g, '>')
Dejan.S
If the output is truly HTML encoded then just replacing angle-brackets won't be enough.
Dan Diplo
yes I know but seem like the fckeditor just remove the < >. It work for the moment, I still have to the full scale html test on it.
Dejan.S
A: 

Why not use the DOM?

function unescapeHTML(html) {
    var htmlNode = document.createElement("div");
    htmlNode.innerHTML = html;
    if(htmlNode.innerText)
    return htmlNode.innerText; // IE
   return htmlNode.textContent; // FF
}

(source)

justkt
great code. dont know if it workes flawless but I will be testing it. thanks justkt
Dejan.S