有谁知道163邮箱的文件上传功能是怎么做的吗? 想做一个类试163邮箱的文件上传功能,上传文件无须刷新页面不用点一下提交才执行上传!!请大虾们指点指点! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 form有个属性叫target,把target设成一个隐藏的iframe的名字,就可以提交form并且页面(form所在的页面)不刷新了 回JK_10000(JK):你的方法我用过,但是163邮箱的文件上传肯定不是用这样的方法。就是想知道163是怎么做的。希望有人指点。 给你段代码css---------------------------------------<style>form{ margin:0; padding:0;}.fileUpArea{ width:63px; height:13px; background:url(http://p.mail.163.com/js31style/lib/0703131650/163blue/f1.gif) no-repeat left top; overflow:hidden;}.fileHover{ width:63px; height:13px; background:url(http://p.mail.163.com/js31style/lib/0703131650/163blue/f1.gif) no-repeat left top; overflow:hidden;}#fileUpArea input{ width:1%;size:0%; position:absolute; margin-left:-16px; z-index:100;filter:alpha(opacity=0);-moz-opacity:0;cursor:point;}* html #fileUpArea input{ margin-top:-5px; margin-left:-10px;}*+html #fileUpArea input{ margin-top:-5px; margin-left:-10px;}#filetxt{ font-size:12px; color:#555; padding:10px;}#filetxt img{ cursor:point;}</style>javascript----------------------var inputCount=1;/*创建 input file*/function CreateFile(){ var container=document.getElementById("fileUpArea"); container.onmouseover=function(event) { this.className="fileHover"; } container.onmouseout=function(event) { this.className="fileUpArea"; } var input=document.createElement("input"); input.type="file"; input.size="1"; input.name="file_"+inputCount; input.id="multi_file_"+inputCount; input.onchange=function(event) { if(CheckFileName(this.value)&&CheckFileNum(5)) { var textName=this.value; textName=textName.substring(textName.lastIndexOf("\\")+1); this.style.display="none"; CreateFile(); var tempid=this.id+"text"; var temptext=textName+"<span style=\"cursor:hand;\" onclick=\"Del('"+tempid+"'),Del('"+this.id+"')\">删除</span>"; CreateText(tempid,temptext); } } container.appendChild(input); inputCount++;}/*检测是否有同名文件*/function CheckFileName(txt){ var container=document.getElementById("fileUpArea"); var ch=container.getElementsByTagName("input"); var rvalue=true; if(ch.length>=2) { for(i=0;i<ch.length-1;i++) { if(ch[i].value==txt) { alert("你已经添加了相同的附件!!!"); rvalue= false; break; } } } return rvalue;}/*检测Element数量 如果节点数目大于等于max则返回false*/function CheckFileNum(max){ var container=document.getElementById("fileUpArea"); var ch=container.getElementsByTagName("input"); if(ch.length-1>=5){ alert("附件最多为"+max+"个!"); return false; } return true;}/*创建显示的文件名称*/function CreateText(id,text){ var contxt=document.createElement("div"); contxt.id=id; contxt.innerHTML=text; document.getElementById("filetxt").appendChild(contxt);}//del by idfunction Del(id){ document.getElementById(id).parentNode.removeChild(document.getElementById(id));}html----------------------------<head></head><script language="javascript" type="text/javascript">window.onload=CreateFile;</script><body><form name="uploadForm" method="post" enctype="multipart/form-data" action="upload.do"><div id="fileUpArea" class="fileUpArea"></div></form><div id="filetxt"></div></body></html> 截取字符串的问题。进来小看一下 Jquery的序列化方法为什么要把空格替换成加号呢? escape(keyword)当KEYWORD为中文时提示参数无效 |zyciis| 如何点击了里面的div的onclick不执行外面div的click 有代码,谢谢 Extjs4.1如何给tree的每个节点都加上复选框 数组查询无法清空 立即给分,在线等--如何利用js获取当然页面得完整URL(含?号后的所有参数) 请教:如何在一个新页面里的OnClick事件中去刷新另一个页面! 请教如何在网页中实现一个可输入的下拉框。 请问如何实现ie工具条上鼠标移上去是突出的效果 求 一正则表达式 计算访问量?
希望有人指点。
css
---------------------------------------
<style>
form{ margin:0; padding:0;}
.fileUpArea{ width:63px; height:13px; background:url(http://p.mail.163.com/js31style/lib/0703131650/163blue/f1.gif) no-repeat left top; overflow:hidden;}
.fileHover{ width:63px; height:13px; background:url(http://p.mail.163.com/js31style/lib/0703131650/163blue/f1.gif) no-repeat left top; overflow:hidden;}
#fileUpArea input{ width:1%;size:0%; position:absolute; margin-left:-16px; z-index:100;filter:alpha(opacity=0);-moz-opacity:0;cursor:point;}
* html #fileUpArea input{ margin-top:-5px; margin-left:-10px;}
*+html #fileUpArea input{ margin-top:-5px; margin-left:-10px;}
#filetxt{ font-size:12px; color:#555; padding:10px;}
#filetxt img{ cursor:point;}
</style>javascript
----------------------
var inputCount=1;
/*创建 input file*/
function CreateFile()
{
var container=document.getElementById("fileUpArea");
container.onmouseover=function(event)
{
this.className="fileHover";
}
container.onmouseout=function(event)
{
this.className="fileUpArea";
}
var input=document.createElement("input");
input.type="file";
input.size="1";
input.name="file_"+inputCount;
input.id="multi_file_"+inputCount;
input.onchange=function(event)
{
if(CheckFileName(this.value)&&CheckFileNum(5))
{ var textName=this.value;
textName=textName.substring(textName.lastIndexOf("\\")+1);
this.style.display="none";
CreateFile();
var tempid=this.id+"text";
var temptext=textName+"<span style=\"cursor:hand;\" onclick=\"Del('"+tempid+"'),Del('"+this.id+"')\">删除</span>";
CreateText(tempid,temptext);
}
}
container.appendChild(input);
inputCount++;
}
/*检测是否有同名文件*/
function CheckFileName(txt)
{
var container=document.getElementById("fileUpArea");
var ch=container.getElementsByTagName("input");
var rvalue=true;
if(ch.length>=2)
{
for(i=0;i<ch.length-1;i++)
{
if(ch[i].value==txt)
{
alert("你已经添加了相同的附件!!!");
rvalue= false;
break;
}
}
}
return rvalue;
}
/*检测Element数量 如果节点数目大于等于max则返回false*/
function CheckFileNum(max){
var container=document.getElementById("fileUpArea");
var ch=container.getElementsByTagName("input");
if(ch.length-1>=5){
alert("附件最多为"+max+"个!");
return false;
}
return true;
}
/*创建显示的文件名称*/
function CreateText(id,text)
{
var contxt=document.createElement("div");
contxt.id=id;
contxt.innerHTML=text;
document.getElementById("filetxt").appendChild(contxt);
}
//del by id
function Del(id)
{
document.getElementById(id).parentNode.removeChild(document.getElementById(id));
}
html
----------------------------
<head>
</head>
<script language="javascript" type="text/javascript">
window.onload=CreateFile;
</script>
<body>
<form name="uploadForm" method="post" enctype="multipart/form-data" action="upload.do">
<div id="fileUpArea" class="fileUpArea">
</div>
</form>
<div id="filetxt"></div>
</body>
</html>