首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CKEDITOR 4.3.2 IE11权限被拒绝

CKEDITOR 4.3.2 IE11权限被拒绝
EN

Stack Overflow用户
提问于 2014-02-08 16:00:24
回答 1查看 3.5K关注 0票数 1

因此,我正在为ckeditor编写一个插件(@)。

当您键入一些字符(例如"@John")时,会出现用户可以选择的Johns列表的下拉列表。当用户选择他们想要的下拉列表时,它需要删除"@John“文本,并插入从下拉列表中检索到的元素。当尝试插入文本、删除某些文本和设置currsor位置时,会出现此问题。

代码

代码语言:javascript
复制
var html = '<span>InsertedElement</span>&nbsp;&nbsp;';
// Create the Element to insert
var newElement = CKEDITOR.dom.element.createFromHtml(html, mentions.editor.document);
//Insert the element
mentions.editor.insertElement(newElement);
//Get a new bookmark
var tempBookMark = mentions.editor.getSelection().createBookmarks(true);
// get the data
var edata = mentions.editor.getData();
// set it with the exact same info so not changes (just for the test)
mentions.editor.setData(edata);
//set the bookmark
mentions.editor.getSelection().selectBookmarks(tempBookMark);
//focas on that position
mentions.editor.focus();

The issue

但是,在删除文本之后,在IE11上,当我尝试访问mentions.editor.getSelection()时,我会得到“拒绝权限”错误。我无法设置书签并将焦点移到ckeditor的开头。

更新我执行的进一步测试缩小了问题范围。注释掉mentions.editor.setData(edata);行它停止错误。如果我对编辑器实例使用setData函数,然后尝试在编辑器实例上运行GetSelection(),则IE11中的错误(权限被拒绝),但在Chrome中工作。setData函数似乎在某种程度上锁定了IE11中的编辑器?我已经简化了代码,以便更容易地复制它。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-10 14:48:34

Editor#setData是一个异步函数。您不能在设置数据之后立即使用选择--您必须等到一切就绪。因此,setData接受回调。

代码语言:javascript
复制
mentions.editor.setData( edata, function() {
    //set the bookmark
    mentions.editor.getSelection().selectBookmarks(tempBookMark);
    //focas on that position
    mentions.editor.focus();
} );
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21648230

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档