innerHtml 和 insideText 破坏 Internet Explorer 中的选项卡
我想获取文本区域的内容并将其放入
中。问题是,如果我将 pre 的 innerHTML-property 设置为 textarea 的值,所有选项卡和换行符都将在 Internet Explorer 中删除。如果我使用innerText而不是innerHtml,我会得到换行符,但选项卡仍然消失。在其他浏览器中运行良好。
有解决办法吗?
I want to take the content of a textarea and put it in a <pre>
. Problem is that if i set the innerHTML-property of the pre to the value of the textarea all tabs and linebreaks will be removed in Internet Explorer. If i use innerText instead of innerHtml i will get the line-breaks but tabs still disappear. Works fine in other browsers.
Is there a solution for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建 DOM 文本节点:
Windows 风格的换行符 (
\r\n
) 是伪造的(DOM 内容应始终将换行符规范化为\n
),但似乎是由于某种原因在 IE 中是必需的。Create a DOM Text node:
The Windows-style newline (
\r\n
) is bogus (DOM content should always have newlines normalised to\n
), but seems to be necessary in IE for some reason.