日期:2014-05-17  浏览次数:20424 次

ckeditor编辑框如何获取焦点?
ckeditor编辑框如何获取焦点?
我用editor.focusManager.focus()和editor.focus()都无效,谁有做过类似的啊?

------解决方案--------------------
先占个沙发

之前我一直以为是别人把fckeditor少打了一个f,结果发现ckeditor是升级版,哎,跟不上了

我先下下来试一下,再回你的贴
------解决方案--------------------
没有用过这个控件,帮顶
------解决方案--------------------
不好获取,这个控件生成后好像其实是一个iframe嵌套页面来的
 没有深入研究。LZ加油
 
------解决方案--------------------
JScript code

//设置ckeditor的焦点,并高亮背景显示  

         function setFocus() {  

             var editor = CKEDITOR.instances.editor1;  

             editor.focus();  

             editor.document.$.body.style.cssText = "background-color:#ff9";  

         }

------解决方案--------------------
现在只试到设置config.js,可以在加载时获取焦点

config.startupFocus = true;
------解决方案--------------------
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <script type="text/javascript" src="ckeditor/ckeditor.js"></script>
    <script type="text/javascript">
    window.onload = function()
    {
        CKEDITOR.replace('tbContent');
    };
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="tbContent" runat="server" TextMode="MultiLine" CssClass="ckeditor">abc</asp:TextBox><br />
        <input type="button" onclick="setFocus();" value="点额" />
    </div>
    </form>
</body>
</html>
    <script type="text/javascript">
    function setFocus() 
    {
        var editor = CKEDITOR.instances.tbContent;  
        editor.focus();
    } 
    </script>