在IE上使用CKEditor插件获取所选文本 [英] Getting selected text with CKEditor Plugin on IE

查看:272
本文介绍了在IE上使用CKEditor插件获取所选文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为CKEditor制作了一个插件,但它依赖于当前选择的文字。

I have made a plugin for CKEditor, but it relies on the currently selected text.

在FF和Chrome中我可以使用:

In FF and Chrome I can use:

var selectedText = editor.getSelection().getNative();  

但这在IE中不起作用,我只得到 [object Object ]

but this doesn't work in IE and I only get [object Object]

有什么建议吗?

推荐答案

这就是我使用的:

var mySelection = editor.getSelection();

if (CKEDITOR.env.ie) {
    mySelection.unlock(true);
    selectedText = mySelection.getNative().createRange().text;
} else {
    selectedText = mySelection.getNative();
}

这篇关于在IE上使用CKEditor插件获取所选文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆