gpt4 book ai didi

internet-explorer - TinyMCE - 在 IE 中的光标位置插入内容不起作用

转载 作者:行者123 更新时间:2023-12-04 07:47:32 25 4
gpt4 key购买 nike

我正在尝试在当前光标位置插入一些内容或替换 TinyMCE 编辑器实例中的选定内容。我正在使用这个:

tinyMCEPopup.editor.selection.setContent(content);

其中 content 是我要插入的 HTML 字符串。

它在 Firefox、Opera 和 Chrome 上运行良好,但在 IE 中无法运行。相反,它在编辑器的开头插入内容,而不是选择。我也试过:

tinyMCEPopup.execCommand('mceInsertContent', false, content);

同样,IE 中的行为相同。用于插入特殊字符的 TinyMCE 代码使用了上面的函数并且有效!我已经尝试在我的插件中复制它,但仍然没有乐趣......

function insertChar(chr) {
tinyMCEPopup.execCommand('mceInsertContent', false, '&#' + chr + ';');

// Refocus in window
if (tinyMCEPopup.isWindow)
window.focus();

tinyMCEPopup.editor.focus();
tinyMCEPopup.close();
}

更新:

仍然无法在 IE 中运行,Opera 甚至没有在工具栏中显示我的插件按钮(尽管这可能是一个单独的问题)!我现在也尝试了 jQuery 插件,让编辑器加载,但无法在其上调用 mceInsertContent 方法,即使使用这个:

$('#my-editor-id').tinymce().execCommand('mceInsertContent', false, content);

出现错误:“对象没有方法:tinymce” - 也许我不能从弹出窗口中调用它?!

最佳答案

你试过打电话吗:

tinyMCEPopup.restoreSelection(); 

打电话之前

tinyMCEPopup.execCommand('mceInsertContent', false, '&#' + chr + ';');

关于internet-explorer - TinyMCE - 在 IE 中的光标位置插入内容不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11204754/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com