请问,如何获取 FCKeditor 内容编辑框 里的文字?

ci__ci 2011-03-11 10:13:33


请问,如何获取 FCKeditor 内容编辑框 里的文字?


不点提交的情况下 如何获取?


我在 fckeditor.html 里

<textarea id="eSourceField" dir="ltr" style="WIDTH: 100%; HEIGHT: 100%">直接加文字</textarea>

直接加文字也没显示出来

...全文
362 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
LKK 2011-03-14
  • 打赏
  • 举报
回复
结合你给的链接http://blog.csdn.net/goody9807/archive/2008/06/30/2597839.aspx

fckplugin.js源码为

var oFormat168Item = new FCKToolbarButton('Format168', FCKLang.Format168Btn); //设置按钮的图标路径
oFormat168Item.IconPath = FCKPlugins.Items['formatcommands'].Path + 'placeholder.gif'; //注册按钮项
FCKToolbarItems.RegisterItem('Format168', oFormat168Item); // The object used for all Format168 operations.
var FCKFormat168 = new Object(); FCKFormat168 = function(name){ this.Name = name; } //FCK_TRISTATE_ON为默认是选中状态 下面的两个方法是实现接口的两个必须的方法,否则会报脚本错误
FCKFormat168.prototype.GetState = function() { return FCK_TRISTATE_OFF; } //此方法是点击按钮后要完成的操作
FCKFormat168.prototype.Execute = function(){ FormatText(); }
//以下都是实现功能的方法
function FormatText() {
var oEditor = FCKeditorAPI.GetInstance('content') ;
var html = oEditor.EditorDocument.body.innerText;
alert(html);
} ;

// Register the related command
FCKCommands.RegisterCommand('Format168', new FCKFormat168('Format168'));


测试可以
ci__ci 2011-03-14
  • 打赏
  • 举报
回复
越看越 不懂了 。。。
技术小黑屋 2011-03-14
  • 打赏
  • 举报
回复
FCKeditor在线编辑器在PHP中的使用
http://blog.csdn.net/BossDarcy/archive/2011/02/26/6210067.aspx
自己总结的,希望对你有帮助
ihefe 2011-03-14
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 lusizeng 的回复:]

HTML code

<input type=button name=btnSubmit value="显示" onClick="showcont()">



JScript code

function showcont(){
var oEditor = FCKeditorAPI.GetInstance('content'); //name值
var checkContent ……
[/Quote]

这是正确,btnSubmit 是你提交内容的按钮。

//jquery button是按钮的CLASS
$(function(){
$(".button").click(function(){
var oEditor = FCKeditorAPI.GetInstance('shop_ad_content'); //name值
var checkContent = oEditor.GetXHTML(); //获取FCKeditor里面的内容
alert(checkContent);
return false;
});
});

参考

http://www.dnbcw.com/biancheng/net/jhzc143106.html
LKK 2011-03-14
  • 打赏
  • 举报
回复
刚看了下
fckeditorcode_ie.js里面有

for ( var name in FCKeditorAPI.Instances ){var oEditor = FCKeditorAPI.Instances[ name ]

oEditor就是FCKeditor对象
ci__ci 2011-03-14
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 lusizeng 的回复:]
引用 6 楼 ci__ci 的回复:

刚刚试了楼上的方法 不行喔
oEditor 是什么,我的JS方法是写在 fckeditorcode_ie.js 里的

晕,我的是写在具体引用页面的,oEditor是FCKeditor的js里面定义的
[/Quote]
因为我需要在工具栏上增加按钮的,所以在fckeditorcode_ie.js 里写了,都弄了好几天了,唉
能不能帮我看看,现在怎么获取
LKK 2011-03-14
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 ci__ci 的回复:]

刚刚试了楼上的方法 不行喔
oEditor 是什么,我的JS方法是写在 fckeditorcode_ie.js 里的
[/Quote]
晕,我的是写在具体引用页面的,oEditor是FCKeditor的js里面定义的
ci__ci 2011-03-14
  • 打赏
  • 举报
回复
在那个HTML里是这样的
<tr id="eWysiwyg">
<td id="eWysiwygCell" height="100%" valign="top">
<iframe id="eEditorArea" name="eEditorArea" height="100%" width="100%" frameborder="no" src="fckblank.html"></iframe>
</td>
</tr>


我尝试用document.getElementById("eWysiwygCell").innerHTML= 是可以插入内容

但用 document.getElementById("eWysiwygCell").value 却是 undefined
ci__ci 2011-03-14
  • 打赏
  • 举报
回复
刚刚试了楼上的方法 不行喔
oEditor 是什么,我的JS方法是写在 fckeditorcode_ie.js 里的
ihefe 2011-03-14
  • 打赏
  • 举报
回复
既然知道了NAME值 JS 就很容易获取
LKK 2011-03-14
  • 打赏
  • 举报
回复

<input type=button name=btnSubmit value="显示" onClick="showcont()">



function showcont(){
var oEditor = FCKeditorAPI.GetInstance('content'); //name值
var checkContent = oEditor.GetXHTML(); //获取FCKeditor里面的内容
alert(checkContent);
}
ci__ci 2011-03-14
  • 打赏
  • 举报
回复
help me please
ci__ci 2011-03-14
  • 打赏
  • 举报
回复
继续求救。。是不是我的FCK版本不同。。
ci__ci 2011-03-14
  • 打赏
  • 举报
回复
fckeditorcode_ie.js 好像没有 NAME值的

全是这些代码
FCK.RedirectNamedCommands=new Object();FCK.ExecuteNamedCommand=function(A,B){FCKUndo.SaveUndoStep();if (FCK.RedirectNamedCommands[A]!=null) FCK.ExecuteRedirectedNamedCommand(A,B);else{FCK.Focus();FCK.EditorDocument.execCommand(A,false,B);FCK.Events.FireEvent('OnSelectionChange');};FCKUndo.SaveUndoStep();};FCK.GetNamedCommandState=function(A){try{if (!FCK.EditorDocument.queryCommandEnabled(A)) return FCK_TRISTATE_DISABLED;else return FCK.EditorDocument.queryCommandState(A)?FCK_TRISTATE_ON:FCK_TRISTATE_OFF;}catch (e){return FCK_TRISTATE_OFF;};};FCK.GetNamedCommandValue=function(A){var B='';var C=FCK.GetNamedCommandState(A);if (C==FCK_TRISTATE_DISABLED) return null;try{B=this.EditorDocument.queryCommandValue(A);}catch(e) {};return B?B:'';};FCK.PasteFromWord=function(){FCKDialog.OpenDialog('FCKDialog_Paste',FCKLang.PasteFromWord,'dialog/fck_paste.html',400,330,'Word');};F
ci__ci 2011-03-14
  • 打赏
  • 举报
回复
非常非常感谢上面这位朋友
不过那个链接的方法好像有点复杂 我后来直接在 FCKConfig.ToolbarSets["Default"] = 里加了一个
然后在相应的fckeditorcode_ie.js里修改 按钮是出来了
但在这个按钮点击事件里,我就需要获取和写入内容 的办法 。。
ihefe 2011-03-11
  • 打赏
  • 举报
回复



include_once(ROOT_PATH . 'includes/fckeditor/fckeditor.php'); // 包含 html editor 类文件

$input_name='content';//name值
$input_value='内容';//value
$editor = new FCKeditor($input_name);
$editor->BasePath = '../includes/fckeditor/';
$editor->ToolbarSet = 'Normal';
$editor->Width = '100%';
$editor->Height = '320';
$editor->Value = $input_value;
$FCKeditor = $editor->CreateHtml();
echo $FCKeditor;//FCKeditor页
ci__ci 2011-03-11
  • 打赏
  • 举报
回复
感谢楼上的 这个是写入内容的办法吧 有没有获取内容的办法 最好是在JS代码里获取,因为我要做一个按钮,点击的时候把内容繁体字转简体字

21,894

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧