由於在FCKeditor的標簽中,並沒有支持html中一些事件,如何直接利用js獲取其中的值就
成為瞭一個問題。
思路:在含有Fckeditor的頁面中利用FCKeditor自動加載的js函數將獲取內容的改值傳遞到一個hidden裡面去,再在父頁面中利用js獲取hidden的值,從而實現對表單的提交
iframe頁面:
Java代碼
<script type="text/javascript">
//FCK會自動加載此函數
function FCKeditor_OnComplete(editorInstance ){
editorInstance.Events.AttachEvent('OnBlur',checkTextValue ) ;
}
//檢查輸入框的情況
function checkTextValue(){
var introducevalue=FCKeditorAPI.GetInstance("EditorDefault").EditorDocument.body.innerText;
//alert(introducevalue);
document.getElementById("hidden").value=introducevalue;
if(introducevalue==""){
alert("內容不能為空");
}
}
</script>
父頁面;
<script type="text/javascript">
function check()
{
alert(window.frames["qq"].document.getElementById("hidden").innerHTML);
}
</script>
作者“勤懇”