由于在FCKeditor的标签中,并没有支持html中一些事件,如何直接利用js获取其中的值就
成为了一个问题。
思路:在含有Fckeditor的页面中利用FCKeditor自动加载的js函数将获取内容的改值传递到一个hidden里面去,再在父页面中利用js获取hidden的值,从而实现对表单的提交
iframe页面:
Java代码
<script type="text/java script">
//FCK会自动加载此函数
function FCKeditor_OnComplete(editorInstance ){
editorInstance.Events.AttachEvent('OnBlur',checkTextValue ) ;
}
//检查输入框的情况
function checkTextValue(){
var introduceva lue=FCKeditorAPI.GetInstance("EditorDefault").EditorDocument.body.innerText;
//alert(introduceva lue);
if(introduceva lue==""){
alert("内容不能为空");
}
}
父页面;
<script type="text/java script">
function check()
{
alert(window.frames["qq"].document.getElementById("hidden").innerHTML);
}
作者“勤恳”