【问题标题】:get the content as well tags of the editable area from iframe editable从 iframe editable 获取内容以及可编辑区域的标签
【发布时间】:2015-10-25 02:44:21
【问题描述】:

我创建了一个小型编辑器,我在其中完成了一些命令作为示例字体格式和
对齐等,因此它在浏览器中工作正常,但我想导出写入的数据
可编辑区域,而我试图在可编辑 iframe 中获取数据,但它给了我一个错误。
错误消息:未捕获的 ReferenceError:innerDoc 未定义
以下代码写成



函数 iFrameOn() {
richTextField.document.designMode = 'On';
}
函数 export_Data() {
var n = document.getElementById("richTextField");
var innerdoc = n.contentDocument || n.contentWindow.document;
var input = innerDoc.getElementsByTagName('body').text;
var zip = new JSZip();
zip.add("hello1.html", ""+输入);
zip.add("hello2.js", "这只是一个简单的文件");
内容 = zip.generate();
location.href="data:application/zip;base64," + content;
脚本>



请帮我解决这个问题

【问题讨论】:

    标签: javascript jquery html xml iframe


    【解决方案1】:

    如果它在同一个域上,试试这个。如果 iframe 的来源与您正在查看的窗口不同,它不会让您访问 iframe 内容。

    var n = document.getElementById("richTextField");
    var innerdoc  = n.contentDocument.body.innerHTML;
    

    【讨论】:

    • 如果我想用它的标签检索全部内容......?这是一些如何工作的。这将对我有很好的帮助
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-14
    • 1970-01-01
    • 2013-08-23
    • 1970-01-01
    • 1970-01-01
    • 2021-12-06
    • 1970-01-01
    相关资源
    最近更新 更多