<script>
function attachFile(){
document.getElementById("file").click();
return;
}
</script>
<form name="novsh" style="margin: 0px; padding: 0px;">
<input type="file" name="file" style="display:none" id="file" />
</form>
<a href="javascript:attachFile()">Attach File</a>
<input type="button" name="btn" value="click me" onclick="attachFile()"/>
我写这样的,它的工作的IE浏览器,但不工作的火狐点击()不工作的火狐
我会考虑能够在文件输入中调用'click()',从而自动打开文件对话框中的安全缺陷。 – RoToRa 2010-05-14 15:09:36
它在其他浏览器中无法正常工作。 http://stackoverflow.com/questions/1829774/jquery-simulating-a-click-on-a-input-typefile-doesnt-work-in-firefox – bobince 2010-05-14 15:20:01