IE 格式化文本区域中的 HTML

发布于 2024-12-22 20:38:42 字数 527 浏览 0 评论 0原文

我正在使用 HTMLBox 在设置页面上创建富文本编辑器。当 HTMLBox 触发时,它会获取文本区域的内容,用可编辑的 div 隐藏文本区域,然后将内容放入该 div 中。当您切换回“纯 HTML”显示时,它会从该 div 中获取内容,将其放回文本区域,并隐藏该 div。这允许您在所见即所得和纯 HTML 之间切换。

我在 Firefox、Chrome 和 Opera 中进行了测试,这些都工作正常,但我在 Internet Explorer 上遇到了问题(惊讶!)。当您在 IE 中切换到基本 HTML 时,它仍然传输内容,但文本区域显示格式化文本,而不是纯 html。因此,如果所见即所得编辑器创建类似

<font color="green">Green Text</font>

基本文本区域的内容,则会以绿色显示“绿色文本”,而不是显示代码。因此,如果用户切换回富文本编辑器,所有标记都将丢失,并且他们将看到未格式化的“绿色文本”。

有没有办法告诉 IE 在文本区域中显示原始 HTML,而不是格式化文本?

I'm using HTMLBox to create a rich text editor on a settings page. When HTMLBox fires, it grabs the content of a textarea, hides the textarea with an editable div, then drops the content into that div. When you switch back to the 'plain HTML' display, it grabs the content from that div, drops it back into the textarea, and hides the div. This allows you to switch between wysiwyg and plain HTML.

I tested in Firefox, Chrome and Opera, and those all work fine, but I'm having a problem with Internet Explorer (surprise!). When you switch to basic HTML in IE, it still transfers the content, but the textarea displays the formatted text, rather than plain html. So if the wysiwyg editor creates something like

<font color="green">Green Text</font>

the basic textarea displays "green text" in green, instead of displaying the code. As a consequence, if the user switches back to the rich text editor, all the markup will be lost, and they'll see unformatted "Green Text".

Is there any way to tell IE to display raw HTML in textareas instead of formatting the text?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不顾 2024-12-29 20:38:42

您必须使用 IE 的等效实体转义 html。

You have to escape the html with its equivalent entities for IE.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文