日期:2014-05-16 浏览次数:20450 次
var objInput=document.createElement("input");//上传控件
objInput.setAttribute("type","file");
objInput.setAttribute("id","file1");
objInput.setAttribute("name","file1");
objInput.style.position="absolute";
objInput.style.width=65+"px";
objInput.style.top=2+"px";
objInput.style.left=1+"px";
objInput.style.height=27+"px";
objInput.style.opacity=0;
objInput.style.filter="alpha(opacity=0)";
objInput.style.cursor="pointer";
objInput.setAttribute("onchange","GetFileName(this);");
var objInput=document.createElement("input");//上传控件
objInput.setAttribute("type","file");
objInput.setAttribute("id","file1");
objInput.setAttribute("name","file1");
objInput.style.position="absolute";
objInput.style.width=65+"px";
objInput.style.top=2+"px";
objInput.style.left=1+"px";
objInput.style.height=27+"px";
objInput.style.opacity=0;
objInput.style.filter="alpha(opacity=0)";
objInput.style.cursor="pointer";
objInput.onchange=function(){GetFileName(this);}////////
//objInput.setAttribute("onchange","GetFileName(this);");
用jquery试试
var $input = $("<input style='position:absoute; width:65px; top:2px; left:1px; height:27px; opacity:0; filter:alpha(opacity=0); cursor:pointer;' />");
$input.attr({'type':'file', 'id':'file1', 'name':'file1'});
$input.change(GetFileName(this));