在wysiHTML5编辑器中以编程方式插入HTML [英] Insert HTML programmatically in wysiHTML5 editor
本文介绍了在wysiHTML5编辑器中以编程方式插入HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我找到了javascript wysiwyg编辑器 wysiHTML5 。
I found javascript wysiwyg editor wysiHTML5.
我正在尝试将元素< a href = ...>
添加到编辑器中,或者只是以编程方式启用粗体。
I'm trying to add element <a href=...>
to the editor or just turn on bold programmatically.
我的代码是:
var editor = new wysihtml5.Editor("textarea", {
toolbar: "toolbar",
stylesheets: "css/wysihtml5.css",
parserRules: wysihtml5ParserRules
});
editor.observe("load", function() {
editor.composer.commands.exec("bold");
});
我做错了什么?
推荐答案
实际上没有,但你必须确保你的textarea(iframe)是专注的。尝试在上使用而不是
观察
。以下是使用insertHTML为我工作的示例代码。
Actually no, but you have to be sure that your textarea (iframe) is focused. Try to use on
instead of observe
. Here is a sample code that worked for me with insertHTML.
editor.on("load", function() {
editor.focus();
editor.composer.commands.exec("insertHTML","<a href=....>text</a>");
});
这篇关于在wysiHTML5编辑器中以编程方式插入HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文