xajax向html页面输出fckeditor是容易的,但是xajax如何获取fckeditor的值?在xajax的wiki上说了,但还是不明白,测试不成功,最后在fckeditor 2.4.3的_samples/html/sample08.html中找到了答案
function GetContents()
{
// Get the editor instance that we want to interact with.
var oEditor = FCKeditorAPI.GetInstance('content1') ;
// Get the editor contents in XHTML.
//alert( oEditor.GetXHTML( true ) ) ; // "true" means you want it formatted.
var a = oEditor.GetXHTML( true );
xajax_show(a);
}
function GetInnerHTML()
{
// Get the editor instance that we want to interact with.
var oEditor = FCKeditorAPI.GetInstance('content1') ;
alert( oEditor.EditorDocument.body.innerHTML ) ;
}
<?php
require_once('./xajax/xajax.inc.php');
$xajax = new xajax();
$xajax->registerFunction('show');
$xajax->registerFunction('load');
$xajax->processRequest();
echo $xajax->getJavascript('./xajax');
//显示编辑器
function show($form) {
$obj = new xajaxResponse();
$obj->alert($form);
return $obj;
}
//根据内容载入编辑器
function load() {
require_once('../../includes/fckeditor/fckeditor.php');
$editor = new fckeditor('content1');
$editor->BasePath = '../../includes/fckeditor/';
$editor->Value = "test";
$content = $editor->createhtml();
$obj = new xajaxResponse();
$obj->assign('content','innerHTML',$content);
return $obj;
}
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<title></title>
<meta name="Description" content="" />
<meta content="" name="Keywords" />
<link rel="stylesheet" rev="stylesheet" href="" type="text/css" media="all" />
<script language="javascript">
<!--
function GetContents()
{
// Get the editor instance that we want to interact with.
var oEditor = FCKeditorAPI.GetInstance('content1') ;
// Get the editor contents in XHTML.
//alert( oEditor.GetXHTML( true ) ) ; // "true" means you want it formatted.
var a = oEditor.GetXHTML( true );
xajax_show(a);
}
function GetInnerHTML()
{
// Get the editor instance that we want to interact with.
var oEditor = FCKeditorAPI.GetInstance('content1') ;
alert( oEditor.EditorDocument.body.innerHTML ) ;
}
//-->
</script>
</head>
<body>
<script language="javascript">
<!--
xajax_load();
//-->
</script>
<form action="" method="post" name="f1" id="f1">
<a href="#" onclick="xajax_load();return false;" title="">载入编辑器</a>
<a href="#" onclick="setTimeout(xajax_show(xajax.getFormValues('f1')),1500);" title="#">获取输入框的值</a>
<a href="#" onclick="GetContents();" title="">获取方式2</a>
<div id="content">
</div>
</form>
</body>
</html>