我可以在 Chrome 开发者工具中看到为 GWT 的 RichTextArea
生成的 html小部件是这样的:
<iframe class="GCJ2VDKDEI" style="height: 40px; ">
#document
<html>
<head></head>
<body>entered text</body>
</html>
</iframe>
有人可以描述一下它是如何工作的吗? <iframe>
中嵌入的页面怎么可能?对用户是可编辑的(看起来和行为像文本区域)?
特别想知道有什么奇怪的#document
事物。这是我第一次看到这样的东西,谷歌没有给我任何答案:(。
最佳答案
它是 iframe 中文档的 Document
节点。 All Document
nodes have a nodeName
property of "#document" ,您可以通过检查 document.nodeName
来查看。 Chrome 的开发人员工具可能通过添加 iframe 的 contentDocument
属性扩展作为 iframe 扩展的子项来处理 iframe。
对于可编辑的文档,所见即所得的编辑器使用 iframe 来编辑内容是很常见的。所有当前的浏览器都允许通过 contenteditable
对任何元素进行内置编辑功能。属性,以及通过 document.designMode
属性在文档级别。
关于javascript - 为 RichTextArea : what is #document? 生成的 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10549008/