如何获取iframe里面的Fckeditor的值
由于在FCKeditor的标签中,并没有支持html中一些事件,如何直接利用js获取其中的值就
成为了一个问题。
思路:在含有Fckeditor的页面中利用FCKeditor自动加载的js函数将获取内容的改值传递到一个hidden里面去,再在父页面中利用js获取hidden的值,从而实现对表单的提交
iframe页面:
<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>