< textarea>自动编码内部的HTML? [英] does <textarea> auto-encode inner html?

查看:307
本文介绍了< textarea>自动编码内部的HTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在< textarea> < / textarea> 标签之间打印一些文字,但我注意到,如果我输入一些字符如< > ,textarea会自动将它们转换为< & gt;





< textarea>< script>< / textarea>



将产生这个HTML



< textarea>& lt; script& gt;< / textarea> / code>



您能解释为什么会发生这种情况吗?

非常感谢,最好的问候。

解决方案

它不会转义内容。 HTML源代码仍然完全相同。它只是具有显示内容的功能,我认为这是< textarea> 标记的要求。


I was trying to print some text between <textarea> and </textarea> tags, but I've noticed that if I input some characters like < and >, textarea automatically converts them to &lt; and &gt;.

Example:

<textarea><script></textarea>

will produce this HTML

<textarea>&lt;script&gt;</textarea>

Can you explain me why this happens?

Thanks in advance, any help is appreciated, best regards.

解决方案

It doesn't escape the contents. The HTML source remains exactly the same. It just has the capability to display the contents as is which I guess is a requirement of the <textarea> tag.

这篇关于&lt; textarea&gt;自动编码内部的HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆