FCKeditor获取选中内容和删除选中内容的方法
FCKeditor获取选中内容和删除选中内容的方法:
// 删除选中内容
FCKeditorAPI.GetInstance("FCKeditor").Selection.Delete();
// so to get the element that is selected, first check the type of the selection
// Doesn't seem to be working in Fx when the selection is only one character - This is due to some bug in the 'GetParentElement' method
if(FCKeditorAPI.GetInstance("FCKeditor").Selection.GetType() == 'Control')
{
alert(FCKeditorAPI.GetInstance("FCKeditor").Selection.GetSelectedElement());
}
else if(FCKeditorAPI.GetInstance("FCKeditor").Selection.GetType() == 'Text')
{
alert(FCKeditorAPI.GetInstance("FCKeditor").Selection.GetParentElement());
}
// 被选中的内容不能通过Selection对象获取,可以使用以下方法:
if (document.all) {
alert(FCKeditorAPI.GetInstance("FCKeditor").EditorDocument.selection.createRange().text);
}
else {
alert(oSel = FCKeditorAPI.GetInstance("FCKeditor").EditorWindow.getSelection());
}
来源://作者:/更新时间:2012-11-25
顶
踩
相关文章:


