HTML: <textarea>-Tag: How to correctly escape HTML and JavaScript content displayed in there?

Posted by jens on Stack Overflow See other posts from Stack Overflow or by jens
Published on 2010-03-23T17:58:31Z Indexed on 2010/03/23 18:03 UTC
Read the original article Hit count: 729

Filed under:
|

Hello,

I have a HTML Tag <textarea>$FOO</textarea> and the $FOO Variable will be filled with arbitrary HTML and JavaScript Content, to be displayed and edited within the textarea. What kind of "escaping" do I neet to apply to $FOO?

I first tought of escaping it HTML but this didnt work (as I will then get shown not the original HTML Code of $FOO but rather the escaped content. This is of course not what I want: I want to be displayed the unescaped HTML/JS Content of the variable...

Is it impossible to display HTML Content within a <textarea> tag and also allow it to be editable as full HTML?

thanks jens

© Stack Overflow or respective owner

Related posts about html

Related posts about textarea