【发布时间】:2019-08-14 15:51:34
【问题描述】:
我在一页上实现了 4 个 TinyMCE 编辑器。我想在用户离开 TinyMCE 编辑器并将编辑器的 html 放入 textarea 时获取编辑器 ID。在模糊时,我可以获得编辑器 html。但我在 Firefox 和 IE 中找不到 iFrame ID。我试过这段代码。
tinyMCE.init({
mode : "textareas",
theme : "advanced",
plugins : "table,insertdatetime,fullscreen,searchreplace,emotions,paste,",
selector: "#vereinbarungen",
selector: "#narration",
theme_advanced_buttons1 : "insertdate,inserttime,|,hr,emotions,|,search,replace,|,cut,copy,paste,pastetext,pasteword,|,forecolor,backcolor,|,bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright, justifyfull,bullist,numlist,undo,redo,|,fullscreen",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "bottom",
theme_advanced_toolbar_align : "left",
extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
plugin_insertdate_dateFormat : "%d.%m.%Y",
plugin_insertdate_timeFormat : "%H:%M:%S",
setup : function(ed) {
ed.onInit.add(function(ed, event) {
var dom = ed.dom,
doc = ed.getDoc(),
el = doc.content_editable ? ed.getBody() : (tinymce.isGecko ? doc : ed.getWin());
tinymce.dom.Event.add(el, 'blur', function(e) {
//this is the targeted iframe id this works in chrome but not works in other browsers.
target_id = el.frameElement.id;
html = $(ed.getBody()).html();
});
});
},
});
当我用 Chrome 尝试这段代码时,我得到了target_id,但是当我用其他浏览器尝试时,el.frameElement 是未定义的。
这个问题的解决方法是什么?
【问题讨论】:
标签: javascript jquery tinymce