xajax向html页面输出fckeditor是容易的,但是xajax如何获取fckeditor的值?在xajax的wiki上说了,但还是不明白,测试不成功,最后在fckeditor 2.4.3的_samples/html/sample08.html中找到了答案
functionGetContents()
{
//Gettheeditorinstancethatwewanttointeractwith.
varoEditor=FCKeditorAPI.GetInstance('content1');
//GettheeditorcontentsinXHTML.
//alert(oEditor.GetXHTML(true)); //"true"meansyouwantitformatted.
vara=oEditor.GetXHTML(true);
xajax_show(a);
}
functionGetInnerHTML()
{
//Gettheeditorinstancethatwewanttointeractwith.
varoEditor=FCKeditorAPI.GetInstance('content1');
alert(oEditor.EditorDocument.body.innerHTML);
}
<?php
require_once('./xajax/xajax.inc.php');
$xajax=newxajax();
$xajax->registerFunction('show');
$xajax->registerFunction('load');
$xajax->processRequest();
echo$xajax->getJavascript('./xajax');
//显示编辑器
functionshow($form){
$obj=newxajaxResponse();
$obj->alert($form);
return$obj;
}
//根据内容载入编辑器
functionload(){
require_once('../../includes/fckeditor/fckeditor.php');
$editor=newfckeditor('content1');
$editor->BasePath='../../includes/fckeditor/';
$editor->Value="test";
$content=$editor->createhtml();
$obj=newxajaxResponse();
$obj->assign('content','innerHTML',$content);
return$obj;
}
?>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<linkrel="icon"href="/favicon.ico"type="image/x-icon"/>
<linkrel="shortcuticon"href="/favicon.ico"type="image/x-icon"/>
<title></title>
<metaname="Description"content=""/>
<metacontent=""name="Keywords"/>
<linkrel="stylesheet"rev="stylesheet"href=""type="text/css"media="all"/>
<scriptlanguage="javascript">
<!--
functionGetContents()
{
//Gettheeditorinstancethatwewanttointeractwith.
varoEditor=FCKeditorAPI.GetInstance('content1');
//GettheeditorcontentsinXHTML.
//alert(oEditor.GetXHTML(true)); //"true"meansyouwantitformatted.
vara=oEditor.GetXHTML(true);
xajax_show(a);
}
functionGetInnerHTML()
{
//Gettheeditorinstancethatwewanttointeractwith.
varoEditor=FCKeditorAPI.GetInstance('content1');
alert(oEditor.EditorDocument.body.innerHTML);
}
//-->
</script>
</head>
<body>
<scriptlanguage="javascript">
<!--
xajax_load();
//-->
</script>
<formaction=""method="post"name="f1"id="f1">
<ahref="http://b1d.ddvip.com/index.php#"onclick="xajax_load();returnfalse;"title="">载入编辑器</a>
<ahref="http://b1d.ddvip.com/index.php#"onclick="setTimeout(xajax_show(xajax.getFormValues('f1')),1500);"title="#">获取输入框的值</a>
<ahref="http://b1d.ddvip.com/index.php#"onclick="GetContents();"title="">获取方式2</a>
<divid="content">
</div>
</form>
</body>
</html>