先提交的 图片上传 (使用ewebeditor中的Img.htm )
ewebeditor 要使用的文件有 buttonimage css dialog indude sysimage UploadFile 文件夹 WEB-INF/Buttom.xml WEB-INF/Style.xml 根目录下 upload.jsp 和 eWebEditor.jsp
Img.jsp
<!--这个源码来自[Code佳源码-http://Codejia.Com],需要更多源码请访问http://Codejia.Com-->
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<style type="text/css">
body, a, table, div, span, td, th, input, select{font:9pt;font-family: "宋体", Verdana, Arial, Helvetica, sans-serif;}
body {padding:5px}
</style>
<script language="JavaScript" src="../dialog/dialog.js"></script>
<script language="JavaScript" src="js/news.js"></script>
<BODY bgColor=menu οnlοad="InitDocument()">
<table border=0 cellpadding=0 cellspacing=0 align=center>
<tr>
<td>
<fieldset>
<legend>图片来源</legend>
<table border=0 cellpadding=0 cellspacing=0>
<tr>
<td colspan=9 height=5></td>
</tr>
<tr>
<td width=7></td>
<td width=54 align=right οnclick="RadioClick('file')"><input type=radio id="d_checkfromfile" value="1" οnclick="RadioClick('file')">上传:</td>
<td width=5></td>
<td colspan=5>
<Script Language=JavaScript>
document.write('<iframe id=d_file frameborder=0 src="../upload.jsp?type=image&style=CoolBlue" width="100%" height="22" scrolling=no></iframe>');
</Script>
</td>
<td width=7></td>
</tr>
<tr>
<td colspan=9 height=5></td>
</tr>
<tr>
<td width=7></td>
<td width=54 align=right οnclick="RadioClick('url')"><input type=radio id="d_checkfromurl" value="1" οnclick="RadioClick('url')">网络:</td>
<td width=5></td>
<td colspan=5><input name="text" type=text id="d_fromurl" style="width:243px" value="" size=30></td>
<td width=7></td>
</tr>
<tr>
<td colspan=9 height=5></td>
</tr>
</table>
</fieldset></td>
</tr>
<tr><td height=5></td></tr>
<tr><td align=right><input type=submit value='确定' id=Ok οnclick="ok()"> <input type=button value='取消' οnclick="window.close();"></td></tr>
</table>
<div id=divProcessing style="width:200px;height:30px;position:absolute;left:70px;top:20px;display:none">
<table border=0 cellpadding=0 cellspacing=1 bgcolor="#000000" width="100%" height="100%"><tr><td bgcolor=#3A6EA5><marquee align="middle" behavior="alternate" scrollamount="5"><font color=#FFFFFF>...图片上传中...请等待...</font></marquee></td></tr></table>
</div>
</body>
</html>
<span style="display:none;">这个源码来自http://Codejia.Com,更多源码请访问<a href="http://Codejia.Com">http://Codejia.Com</a> <a href="http://9host.cn">虚拟主机</a> <a href="http://15883.com">免费域名</a> <a href="http://bestmoban.com">网页模版</a></span>
news.js
var sFromUrl = "http://";
// 初始值
function InitDocument(){
d_fromurl.value = sFromUrl;
RadioClick('file');
}
// 图片来源单选点击事件
function RadioClick(what){
if (what=="url"){
d_checkfromfile.checked=false;
d_fromurl.disabled=false;
d_checkfromurl.checked=true;
d_file.myform.uploadfile.disabled=true;
}else{
d_checkfromurl.checked=false;
d_file.myform.uploadfile.disabled=false;
d_checkfromfile.checked=true;
d_fromurl.disabled=true;
}
}
// 上传错误
function UploadError(sErrDesc){
AbleItems();
RadioClick('file');
divProcessing.style.display="none";
try {
BaseAlert(d_file.myform.uploadfile,sErrDesc);
}
catch(e){}
}
// 文件上传完成时执行,带入上传文件名
function UploadSaved(sFileName){
d_fromurl.value=GetHttpUrl("UploadFile/"+sFileName);
ReturnValue();
}
// 本窗口返回值
function ReturnValue(){
sFromUrl = d_fromurl.value;
window.returnValue = sFromUrl;
window.close();
}
// 点确定时执行
function ok(){
// 上传文件判断
if (d_checkfromurl.checked){
// 返回值
ReturnValue();
}
else
{
if (!d_file.CheckUploadForm()) return false;
// 使各输入框无效
DisableItems();
// 显示正在上传图片
divProcessing.style.display="";
// 上传表单提交
d_file.myform.submit();
}
}
// 使所有输入框无效
function DisableItems(){
d_checkfromfile.disabled=true;
d_checkfromurl.disabled=true;
d_fromurl.disabled=true;
Ok.disabled=true;
}
// 使所有输入框有效
function AbleItems(){
d_checkfromfile.disabled=false;
d_checkfromurl.disabled=false;
d_fromurl.disabled=false;
Ok.disabled=false;
}
// 显示无模式对话框
function ShowDialog(url, width, height) {
var arr = window.showModalDialog(url,window,"dialogWidth:" + width + "px;dialogHeight:" + height + "px;help:no;scroll:no;status:no");
return arr;
}
//添加上传图片事件
function getPicture()
{
var sPicture = ShowDialog('Img.htm',350,140)
if(sPicture!=null)
{
document.AddNews.NewsPicture.value = sPicture;
}
}
实现页 add.jsp
<script type="text/javascript">
function checkspace(checkstr) {
var str = '';
for(i = 0; i < checkstr.length; i++) {
str = str + ' ';
}
return (str == checkstr);
}
function check(){
if(checkspace(myEditor.getHTML())){
alert('请输入歌词!');
myEditor.focus();
return false;
}
formadd.lyric.value=myEditor.getHTML();
document.formadd.submit();
}
function getPicture()
{
var sPicture = ShowDialog("Img.htm",350,140);
if(sPicture!=null)
{
document.formadd.NewsPicture.value = sPicture;
}
}
// 显示无模式对话框
function ShowDialog(url, width, height) {
var arr = window.showModalDialog(url,window,"dialogWidth:" + width + "px;dialogHeight:" + height + "px;help:no;scroll:no;status:no");
return arr;
}
</script>
<form name="formadd" method="POST" action="add_do.jsp">
<tr>
<td>歌曲图标:</td><td><input name="NewsPicture" type="text" class="chinese" id="NewsPicture" size=25 maxlength="80" style="display:" value="">
<input name="UpImg" type="button" class="button" id="UpImg"
onClick="getPicture()" value="上传歌曲图标>>"> </td></tr>
<tr>
<td width="130" height="25" align="right">歌词:</td>
<td height="25" colspan="2"> </td>
</tr>
<tr>
<td height="25" colspan="3"><div align="center">
<textarea name="lyric" class="chinese" style="display:none"></textarea>
<iframe ID="myEditor" src="../eWebEditor.jsp?id=lyric&style=CoolBlue" frameborder="0" scrolling="no" width="620" height="350"></iframe>
</div></td>
</tr>
<tr>
<td colspan=3><p align="center"><br>
<input type="submit" value="保 存" class="leftbutton" onClick="javascript:return check()">
<br>
<br><br></p></td>
</tr>
</form>