一个关于eWebEditor JSP版的问题 JSP版的eWebEditor当服务起来以后,进入页面,出现webeditor编辑框,当编辑框里什么也不写的时候,不写任何文字,图片,要编辑框干干净净,包括空格也不能有,这时候提交,看看会出现什么样的后果.看服务,是不是停了,这算是至命的问题吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 顶了 我也遇到过这样问题 一直没解决 点提交按钮时,不管用JS怎么验证 都会把表单提交到服务器 服务器取不到webeditor中的数据 问题的原因是webeditor.JSP里有个表单并不会受JS验证的干扰 它总是会被提交 <HTML><HEAD><TITLE>eWebEditor : 标准调用示例</TITLE><META http-equiv=Content-Type content="text/html; charset=gb2312"><link rel='stylesheet' type='text/css' href='example.css'></HEAD><BODY><p><b>导航 : <a href="default.htm">示例首页</a> > 标准调用示例</b></p><p>此例演示了eWebEditor的标准调用方法,也是最常用的调用方法。</p><p>本样式使用系统的默认样式(coolblue),最佳调用宽度550px,最佳调用高度350px。</p><FORM method="post" name="myform" action="retrieve.asp"><TABLE border="0" cellpadding="2" cellspacing="1"><TR> <TD>编辑内容:</TD> <TD> <INPUT type="hidden" name="content1" value="<P align=center><FONT color=#ff0000><FONT face='Arial Black' size=7><STRONG>eWeb<FONT color=#0000ff>Editor</FONT><FONT color=#000000><SUP>™</SUP></FONT></STRONG></FONT></FONT></P><P align=right><FONT style='BACKGROUND-COLOR: #ffff00' color=#ff0000><STRONG>eWebEditor V4.6 简体中文精简版</STRONG></FONT></P><P>本样式为系统默认样式(coolblue),最佳调用宽度550px,高度350px!</FONT></P><P>还有一些高级调用功能的例子,你可以通过导航进入示例首页查看。</P><P><B><TABLE borderColor=#ff9900 cellSpacing=2 cellPadding=3 align=center bgColor=#ffffff border=1 heihgt=''><TBODY><TR><TD bgColor=#00ff00><STRONG> 看到这些内容,且没有错误提示,说明安装已经正确完成!</STRONG></TD></TR></TBODY></TABLE></B></P>"> <IFRAME ID="eWebEditor1" src="../ewebeditor.htm?id=content1&style=coolblue" frameborder="0" scrolling="no" width="550" height="350"></IFRAME> </TD></TR><TR> <TD colspan=2 align=right> <INPUT type=submit value="提交"> <INPUT type=reset value="重填"> <INPUT type=button value="查看源文件" onclick="location.replace('view-source:'+location)"> </TD></TR></TABLE></FORM></BODY></HTML>验证下会不行??<INPUT type=submit value="提交"> 另外后台不都是自己写的吗 回楼上的(3楼):你的说的那种办法不行,你的value里是有值的,我说的是,把这些东西都删除了, 之后在提交,而且什么也不能有,哪怕是一个空格,提交1楼说的好; 因为值copy是在submit时完成的,ew覆盖了sumbit的方法把原submit方法改名为originalSubmit方法了。下面是实现的源码, oForm.attachEvent("onsubmit", AttachSubmit) ; if (! oForm.submitEditor) oForm.submitEditor = new Array() ; oForm.submitEditor[oForm.submitEditor.length] = AttachSubmit ; if (! oForm.originalSubmit) { oForm.originalSubmit = oForm.submit ; oForm.submit = function() { if (this.submitEditor) { for (var i = 0 ; i < this.submitEditor.length ; i++) { this.submitEditor[i]() ; } } this.originalSubmit() ; } }保持我原有观点1。不会影响后台2。前台仍然是可以校验的。 漏了最关键的function AttachSubmit() { var oForm = oLinkField.form ; if (!oForm) {return;} var html = getHTML(); ContentEdit.value = html; if (sCurrMode=="TEXT"){ html = HTMLEncode(html); } splitTextField(oLinkField, html);} 给你写了个demo<HTML><HEAD><TITLE>eWebEditor : 标准调用示例</TITLE><META http-equiv=Content-Type content="text/html; charset=gb2312"><link rel='stylesheet' type='text/css' href='example.css'><script> function validateForm(){ window.frames["eWebEditor1"].AttachSubmit(); if(document.getElementById("content1").value!=""){ document.getElementById("myform").submit(); }else{ alert("空"); } }</script></HEAD><BODY><FORM method="post" name="myform" action="rs.jsp"><TABLE border="0" cellpadding="2" cellspacing="1"><TR> <TD>编辑内容:</TD> <TD> <INPUT type="hidden" name="content1" > <IFRAME ID="eWebEditor1" src="../ewebeditor.htm?id=content1&style=coolblue" frameborder="0" scrolling="no" width="550" height="350"></IFRAME> </TD></TR><TR> <TD colspan=2 align=right> <INPUT type=button value="提交" onclick="validateForm()"> <INPUT type=reset value="重填"> <INPUT type=button value="查看源文件" onclick="location.replace('view-source:'+location)"> </TD></TR></TABLE></FORM></BODY></HTML> 我把我写的代码发上来,看看哪不对吧,(楼上)<html><head><title>eWebEditor : 标准调用示例</title><meta http-equiv=Content-Type content="text/html; charset=gb2312"/><link rel='stylesheet' type='text/css' href='example.css'/><script>function AttachSubmit() { var oForm = oLinkField.form ; if (!oForm) {return;} var html = getHTML(); ContentEdit.value = html; if (sCurrMode=="TEXT"){ html = HTMLEncode(html); } splitTextField(oLinkField, html);} function validateForm(){ oForm.attachEvent("onsubmit", AttachSubmit) ; if (! oForm.submitEditor) oForm.submitEditor = new Array() ; oForm.submitEditor[oForm.submitEditor.length] = AttachSubmit ; if (! oForm.originalSubmit) { oForm.originalSubmit = oForm.submit ; oForm.submit = function() { if (this.submitEditor) { for (var i = 0 ; i < this.submitEditor.length ; i++) { this.submitEditor[i]() ; } } this.originalSubmit() ; } } window.frames["eWebEditor1"].AttachSubmit(); if(document.getElementById("content1").value!=""){ document.getElementById("myform").submit(); }else{ alert("空"); return false(); } } </script></head><body><form method="post" name="myform" action="rs.jsp"><table border="0" cellpadding="2" cellspacing="1"><tr> <td>编辑内容:</td> <td> <input type="hidden" name="content1" /> <iframe id="eWebEditor1" src="eWebEditor/eWebEditor.jsp?id=content1&style=coolblue" frameborder="0" scrolling="no" width="650" height="450"></iframe> </td></tr><tr> <td colspan=2 align=right> <input type=button value="提交" onclick="return validateForm()"/> <input type=reset value="重填"/> <input type=button value="查看源文件" onclick="location.replace('view-source:'+location)"/> </td></tr></table></form></body></html>这时候会出两个错误:一个是oForm没有定义,一个是oLinkField没有定义,我不知道你说的这两个方法和顺是否有关系.我现在对这个了解的也不是太深,你写的那些方法我也看不懂是什么意思 这样就可以了。更多信息可参考我的bloghttp://blog.csdn.net/sunyujia/archive/2008/06/21/2572861.aspx<HTML><HEAD><TITLE>eWebEditor : 标准调用示例</TITLE><META http-equiv=Content-Type content="text/html; charset=gb2312"><link rel='stylesheet' type='text/css' href='example.css'><script> function validateForm(){ window.frames["eWebEditor1"].AttachSubmit(); if(document.getElementById("content1").value!=""){ document.getElementById("myform").submit(); }else{ alert("空"); } }</script></HEAD><BODY><FORM method="post" name="myform" action="rs.jsp"><TABLE border="0" cellpadding="2" cellspacing="1"><TR> <TD>编辑内容:</TD> <TD> <INPUT type="hidden" name="content1" > <IFRAME ID="eWebEditor1" src="../ewebeditor.htm?id=content1&style=coolblue" frameborder="0" scrolling="no" width="550" height="350"></IFRAME> </TD></TR><TR> <TD colspan=2 align=right> <INPUT type=button value="提交" onclick="validateForm()"> <INPUT type=reset value="重填"> <INPUT type=button value="查看源文件" onclick="location.replace('view-source:'+location)"> </TD></TR></TABLE></FORM></BODY></HTML> 我在5,6楼贴的是ewebeditor的源代码,做分析用的。实际上最关键的是在取值之前同步下就可以了 window.frames["eWebEditor1"].AttachSubmit(); 我把javascript帖出来:这种方法,依然会出同样的错误,服务器停止,function validateForm(){ window.frames["eWebEditor1"].AttachSubmit(); if(document.getElementById("content1").value!=""){ document.getElementById("myform").submit(); }else{ alert("空"); return false; } }这种方法到可以提示为空,可是输入东西了,也提示空function validateForm(){ if(document.getElementById("content1").value!=""){ window.frames["eWebEditor1"].AttachSubmit(); document.getElementById("myform").submit(); }else{ alert("空"); return false; } }是不是你我用的版本不一样,所以出现的问题也就不一样呢?这个和版本有关系吗? struts2出错Unable to load configuration. - action - file:/D:/workspace/…… 如何学习jquery。 急、急、急、、、 struct问题 外包 图片处理 js截取字符串中一对中括号间的内容 jsp 博客源码下载 servlet 中request跳转传值的问题 ofbiz 3.0 初级问题,高手来接分 请问如何在JSP页面中实现图形附加码?我只实现了数字附加码,听说PHP有“GD库”,那我深爱的JSP能实现吗? 关于文件上传组件SmartUpload使用失败的问题 基于struts的企业人事信息管理系统的设计与实现
点提交按钮时,不管用JS怎么验证 都会把表单提交到服务器 服务器取不到webeditor中的数据 问题的原因是webeditor.JSP里有个表单并不会受JS验证的干扰 它总是会被提交
<HTML>
<HEAD>
<TITLE>eWebEditor : 标准调用示例</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<link rel='stylesheet' type='text/css' href='example.css'>
</HEAD>
<BODY><p><b>导航 : <a href="default.htm">示例首页</a> > 标准调用示例</b></p>
<p>此例演示了eWebEditor的标准调用方法,也是最常用的调用方法。</p>
<p>本样式使用系统的默认样式(coolblue),最佳调用宽度550px,最佳调用高度350px。</p>
<FORM method="post" name="myform" action="retrieve.asp">
<TABLE border="0" cellpadding="2" cellspacing="1">
<TR>
<TD>编辑内容:</TD>
<TD>
<INPUT type="hidden" name="content1" value="<P align=center><FONT color=#ff0000><FONT face='Arial Black' size=7><STRONG>eWeb<FONT color=#0000ff>Editor</FONT><FONT color=#000000><SUP>™</SUP></FONT></STRONG></FONT></FONT></P><P align=right><FONT style='BACKGROUND-COLOR: #ffff00' color=#ff0000><STRONG>eWebEditor V4.6 简体中文精简版</STRONG></FONT></P><P>本样式为系统默认样式(coolblue),最佳调用宽度550px,高度350px!</FONT></P><P>还有一些高级调用功能的例子,你可以通过导航进入示例首页查看。</P><P><B><TABLE borderColor=#ff9900 cellSpacing=2 cellPadding=3 align=center bgColor=#ffffff border=1 heihgt=''><TBODY><TR><TD bgColor=#00ff00><STRONG> 看到这些内容,且没有错误提示,说明安装已经正确完成!</STRONG></TD></TR></TBODY></TABLE></B></P>">
<IFRAME ID="eWebEditor1" src="../ewebeditor.htm?id=content1&style=coolblue" frameborder="0" scrolling="no" width="550" height="350"></IFRAME>
</TD>
</TR>
<TR>
<TD colspan=2 align=right>
<INPUT type=submit value="提交">
<INPUT type=reset value="重填">
<INPUT type=button value="查看源文件" onclick="location.replace('view-source:'+location)">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>验证下会不行??
<INPUT type=submit value="提交">
另外后台不都是自己写的吗
你的说的那种办法不行,你的value里是有值的,我说的是,把这些东西都删除了, 之后在提交,而且什么也不能有,哪怕是一个空格,提交1楼说的好;
下面是实现的源码, oForm.attachEvent("onsubmit", AttachSubmit) ;
if (! oForm.submitEditor) oForm.submitEditor = new Array() ;
oForm.submitEditor[oForm.submitEditor.length] = AttachSubmit ;
if (! oForm.originalSubmit) {
oForm.originalSubmit = oForm.submit ;
oForm.submit = function() {
if (this.submitEditor) {
for (var i = 0 ; i < this.submitEditor.length ; i++) {
this.submitEditor[i]() ;
}
}
this.originalSubmit() ;
}
}保持我原有观点
1。不会影响后台
2。前台仍然是可以校验的。
var oForm = oLinkField.form ;
if (!oForm) {return;}
var html = getHTML();
ContentEdit.value = html;
if (sCurrMode=="TEXT"){
html = HTMLEncode(html);
}
splitTextField(oLinkField, html);
}
<HEAD>
<TITLE>eWebEditor : 标准调用示例</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<link rel='stylesheet' type='text/css' href='example.css'>
<script>
function validateForm(){
window.frames["eWebEditor1"].AttachSubmit();
if(document.getElementById("content1").value!=""){
document.getElementById("myform").submit();
}else{
alert("空");
}
}
</script>
</HEAD>
<BODY>
<FORM method="post" name="myform" action="rs.jsp">
<TABLE border="0" cellpadding="2" cellspacing="1">
<TR>
<TD>编辑内容:</TD>
<TD>
<INPUT type="hidden" name="content1" >
<IFRAME ID="eWebEditor1" src="../ewebeditor.htm?id=content1&style=coolblue" frameborder="0" scrolling="no" width="550" height="350"></IFRAME>
</TD>
</TR>
<TR>
<TD colspan=2 align=right>
<INPUT type=button value="提交" onclick="validateForm()">
<INPUT type=reset value="重填">
<INPUT type=button value="查看源文件" onclick="location.replace('view-source:'+location)">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
<head>
<title>eWebEditor : 标准调用示例</title>
<meta http-equiv=Content-Type content="text/html; charset=gb2312"/>
<link rel='stylesheet' type='text/css' href='example.css'/>
<script>function AttachSubmit() {
var oForm = oLinkField.form ;
if (!oForm) {return;}
var html = getHTML();
ContentEdit.value = html;
if (sCurrMode=="TEXT"){
html = HTMLEncode(html);
}
splitTextField(oLinkField, html);
}
function validateForm(){
oForm.attachEvent("onsubmit", AttachSubmit) ;
if (! oForm.submitEditor) oForm.submitEditor = new Array() ;
oForm.submitEditor[oForm.submitEditor.length] = AttachSubmit ;
if (! oForm.originalSubmit) {
oForm.originalSubmit = oForm.submit ;
oForm.submit = function() {
if (this.submitEditor) {
for (var i = 0 ; i < this.submitEditor.length ; i++) {
this.submitEditor[i]() ;
}
}
this.originalSubmit() ;
}
}
window.frames["eWebEditor1"].AttachSubmit();
if(document.getElementById("content1").value!=""){
document.getElementById("myform").submit();
}else{
alert("空");
return false();
}
}
</script>
</head>
<body>
<form method="post" name="myform" action="rs.jsp">
<table border="0" cellpadding="2" cellspacing="1">
<tr>
<td>编辑内容:</td>
<td>
<input type="hidden" name="content1" />
<iframe id="eWebEditor1" src="eWebEditor/eWebEditor.jsp?id=content1&style=coolblue" frameborder="0" scrolling="no" width="650" height="450"></iframe>
</td>
</tr>
<tr>
<td colspan=2 align=right>
<input type=button value="提交" onclick="return validateForm()"/>
<input type=reset value="重填"/>
<input type=button value="查看源文件" onclick="location.replace('view-source:'+location)"/>
</td>
</tr>
</table>
</form>
</body>
</html>这时候会出两个错误:一个是oForm没有定义,一个是oLinkField没有定义,
我不知道你说的这两个方法和顺是否有关系.
我现在对这个了解的也不是太深,你写的那些方法我也看不懂是什么意思
更多信息可参考我的blog
http://blog.csdn.net/sunyujia/archive/2008/06/21/2572861.aspx<HTML>
<HEAD>
<TITLE>eWebEditor : 标准调用示例</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<link rel='stylesheet' type='text/css' href='example.css'>
<script>
function validateForm(){
window.frames["eWebEditor1"].AttachSubmit();
if(document.getElementById("content1").value!=""){
document.getElementById("myform").submit();
}else{
alert("空");
}
}
</script>
</HEAD>
<BODY>
<FORM method="post" name="myform" action="rs.jsp">
<TABLE border="0" cellpadding="2" cellspacing="1">
<TR>
<TD>编辑内容:</TD>
<TD>
<INPUT type="hidden" name="content1" >
<IFRAME ID="eWebEditor1" src="../ewebeditor.htm?id=content1&style=coolblue" frameborder="0" scrolling="no" width="550" height="350"></IFRAME>
</TD>
</TR>
<TR>
<TD colspan=2 align=right>
<INPUT type=button value="提交" onclick="validateForm()">
<INPUT type=reset value="重填">
<INPUT type=button value="查看源文件" onclick="location.replace('view-source:'+location)">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
实际上最关键的是在取值之前同步下就可以了
window.frames["eWebEditor1"].AttachSubmit();
function validateForm(){
window.frames["eWebEditor1"].AttachSubmit();
if(document.getElementById("content1").value!=""){
document.getElementById("myform").submit();
}else{
alert("空");
return false;
}
}这种方法到可以提示为空,可是输入东西了,也提示空
function validateForm(){
if(document.getElementById("content1").value!=""){
window.frames["eWebEditor1"].AttachSubmit();
document.getElementById("myform").submit();
}else{
alert("空");
return false;
}
}
是不是你我用的版本不一样,所以出现的问题也就不一样呢?
这个和版本有关系吗?