src.toLowerCase().indexOf("file://")!=0)
{
alert("只能上传本地文件!!\n请把文件框的内容清楚\n然后按浏览");
file.focus();
return false;
}
if(preview.fileSize==0)
{
file.focus();
return false;
}
return preview.fileSize;
}
function Check_Form()
{
if(event==null)var event=new Object();
var totalSize=0;
var haveItem=false;
var coll=form_submit.children;
for(var i=0;i<coll.length;i++)
{
var item=coll.item(i);
if(item.className.toLowerCase()=="form_item")
{
haveItem=true;
totalSize=Check_Item(item);
if(totalSize==false)
{
alert("该输入框必须填上正确的内容");
return event.returnValue=false;
}
}
}
if(haveItem==false)
{
Add_FormItem();
return event.returnValue=false;
}
if(totalSize==0)
{
alert("不打算上传了");//暂时没有可能执行
return event.returnValue=false;
}
if(totalSize>1024*1024)
{
alert("不能上传超过1M的数据");
return event.returnValue=false;
}
btn_submit.disabled=true;
return event.returnValue=true;
}
function Add_FormItem()
{
form_submit.elements("input_submit").insertAdjacentHTML("beforebegin",form_template.innerHTML);
}
function Delete_FormItem()
{
var btn=event.srcElement;
GetItemDiv(btn).removeNode(true);
}
function Show_Preview()
{
var div=GetItemDiv(event.srcElement);
var preview=GetNamedItem(div,"preview");
var file=GetNamedItem(div,"file");
if(preview.readyState=="uninitialized"||preview.readyState=="complate")countImgLoading++;
btn_submit.disabled=true;
preview.src=file.value;
}
function OnPreviewLoad(secceed)
{
btn_submit.disabled=false;//bug:当表单在提交的时候,忽略
countImgLoading--;
var div=GetItemDiv(event.srcElement);
var preview=GetNamedItem(div,"preview");
var height=GetNamedItem(div,"height");
var width=GetNamedItem(div,"width");
if(secceed)
{
height.value=preview.height;
width.value=preview.width;
}
else
{
height.value=width.value="0";
}
var filesize=GetNamedItem(div,"filesize");
filesize.innerText=Math.floor(preview.fileSize/1024)+"K";
}
function OnPreviewMouseOver(div)
{
if(div.contains(event.fromElement))return;
var divItem=GetItemDiv(div);
var preview=GetNamedItem(divItem,"preview");
div.style.overflow="visible";
preview.style.position="absolute";
}
function OnPreviewMouseOut(div)
{
if(div.contains(event.toElement))return;
var divItem=GetItemDiv(div);
var preview=GetNamedItem(divItem,"preview");
div.style.overflow="hidden";
preview.style.position="static";
}
function OnPreviewClick(div)
{
var divItem=GetItemDiv(event.srcElement);
var preview=GetNamedItem(divItem,"preview");
div.style.overflow="hidden";
preview.style.position="static";
}
</SCRIPT>
<BODY>
<DIV>
<BUTTON ID="btn_add">添加一个需要上传的
图片</BUTTON>
<BUTTON ID="btn_submit">提交所有内容</BUTTON>
</DIV>
<DIV>
<FORM ID="form_submit" ACTION="e.g.jscript.action.as