setup/개발 관련2010. 4. 7. 16:01

#FCKeditor 적용하기
방법 1> php include
적용하려는 파일에 아래 소스를 적용한다.
경로>http://localhost/fckeditor_load.php : fckeditor_load.php(본인이 만든 파일)

소스예>
<?php include "/fckeditor/fckeditor.php"; ?>

fckeditor가 삽입될 위치에 다음의 소스를 삽입한다.

<?php
$objFCK= new FCKeditor('content');         // textarea name
$objFCK->BasePath = '/fckeditor/';
$objFCK->Value      = $content ;              // 로딩시 출력할 내용
$objFCK->Width      = 400;                       // 가로 크기

$objFCK->Height     = 300;                       // 세로 크기
$objFCK->Create();
?>

방법2> javascript
소스예> http://okkks.tistory.com/703


방법3> javascript
소스예>
<form>
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
<script type="text/javascript">
var objFCK= new FCKeditor('FCKeditor1');

objFCK.BasePath = "/fckeditor/";
objFCK.Create();
</script>
</form>


방법4>ajax
var div = document.getElementById("FCKeditor1");
var objFCK= new FCKeditor("FCKeditor1");
div.innerHTML = objFCK.CreateHtml();


[null을 체크하려면?]

<script type="text/javascript">
<!--
var objFCK = FCKeditorAPI.GetInstance('FCKeditor1') ;
var div = document.createElement("DIV");

div.innerHTML = objFCK.GetXHTML();

if( div.innerText == '' )
{
 alert("글 내용을 입력하세요.^^");
 objFCK.Focus();
 return;
}
//-->
</script>

<script type="text/javascript">
<!--
var objFCK = FCKeditorAPI.GetInstance('content') ;
var content = objFCK.GetXHTML(true);

if(content == ""){
 alert('글 내용을 입력하세요.^^');
 return false;
}
//-->
</script>

Posted by 은둔고수