在动态网站中有很多在线文本编辑器可以用来进行类似于word一样功能的文本编辑工作 ,它可以作为表单的一部分,向服务器提供文本内容。应用最广泛的是ewebeditor
当表单内用iframe方式嵌入文本编辑器,在表单提交时,常规方法并不能得到文本编辑器中的文本内容。需要在表单内新加隐藏文本域,在提交时用javascript把文本编辑器内容赋值给文本域。代码如下:
在表单内插入隐藏的表单文本域,并用iframe方法嵌入文本编辑器
<textarea name="temp" style="display:none;"></textarea>//加入隐藏文本域
<IFRAME ID="eWebEditor" src="eWebEditor/ewebeditor.htm?id=temp&style=blue" frameborder="0" scrolling="no" width="690" height="500"></IFRAME>//嵌入文本编辑器
<IFRAME ID="eWebEditor" src="eWebEditor/ewebeditor.htm?id=temp&style=blue" frameborder="0" scrolling="no" width="690" height="500"></IFRAME>//嵌入文本编辑器
在网页body前加上JAVASCRIPT方法.form2为表单name
<script language="javascript">
function subchk()
...{
document.form2.temp.value= window.eWebEditor.gettext();
}
</script>
function subchk()
...{
document.form2.temp.value= window.eWebEditor.gettext();
}
</script>
onsubmit调用JS
<form name="form2" method="post" action="news.php?addnews=1" onSubmit="subchk()">
这样表单提交时,文本编辑器的内容就取到temp中了