1

我在我的网站上使用 openWysiWyg 编辑器。这附加到一个文本区域,我可以在其中输入内容,然后将内容保存到一些 html 标记完整的 php 文本文件中。在我网站的视图页面中,我直接包含了这个 php 文件,一切正常。

最近,我收到一些请求,希望能够重新编辑已经提交的文本。为此,我使用附加到 textarea 的相同编辑器,我读取文件的内容并将其作为 .textarea 传递给 textarea。内容被加载到文本区域,一切都很好,除了以下问题。如果我尝试重新编辑类似“ & lt ;pankaj & gt; ”之类的内容 - 在编辑器中加载此内容后,它会在提交新更改时转换为“ < pankaj ></pankaj > ”。所以我有两个问题 - 为什么“ & lt ; ” 被转换为 ' < ' 以及为什么会发生这种标签的自动完成。

我发现编辑器执行以下步骤:

  1. 在一些字符串中取 textarea.value
  2. 使用 document.write() 将该值复制到 texarea 的 div 中,该 div 本身就是一个 iframe。
  3. 提交后需要 object.innerHTML 来获取内容,然后我将其保存到磁盘

文本不会发生上述问题 - “ i & lt; 5 ”。

4

1 回答 1

0

why "& lt ;" is getting converted to '<'

The editor is disabling the escape character &lt; and replacing it with the literal <

why is this auto-completion of tags happening.

The editor is converting the unescaped tag to valid XHTML

the above issues doesnt happen for text - "i & lt ; 5".

That is a numeric comparison, not markup

于 2014-06-21T01:32:45.483 回答