【问题标题】:Capture event when iframe content changes在 iframe 内容更改时捕获事件
【发布时间】:2015-05-13 17:41:37
【问题描述】:

我正在使用SCEditor 插件 作为富编辑。这个插件在我的 html 页面中生成一个 iframe。当我键入所有内容时,此编辑器会在该 iframe 中添加一些 html 元素。现在,我需要捕获更改 iframe 内容的事件。我该怎么做?

这是插件生成的html代码:

<div id="editor" ... >
     ...
    <iframe>
       <!DOCTYPE html>
       <html>
          <head>...</head>
          <body>
              //This content changes when i type every thing
          </body>
      </html>
    </iframe>
</div>

【问题讨论】:

    标签: jquery events iframe rich-text-editor sceditor


    【解决方案1】:

    使用

    $(pointerToContainerEditor).sceditor('instance')
    

    (考虑 $(pointerToContainerEditor) 一个变量,其中包含与您使用 .sceditor() 方法初始化 SCE 相同的变量。)
    获取您正在使用的编辑器实例。然后使用方法

    http://www.sceditor.com/api/sceditor/bind/
    +
    http://www.sceditor.com/api/sceditor/val/

    使用.bind() 向编辑器添加事件监听器。最常见的 DOM 事件可用。 使用.val() 获取当前模式下的当前值。阅读上面的链接以获取更多信息,如果您仍然没有得到它,请随时询问。

    【讨论】:

      猜你喜欢
      • 2013-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-12
      • 2014-07-17
      • 1970-01-01
      相关资源
      最近更新 更多