用sendKeys很容易就做到了,想想其他方法?
<script>
function window.onload(){
t.focus();
var WshShell=new ActiveXObject("WScript.Shell")
WshShell.sendKeys("c:\\4.gif")
}
</script>
<input id=t type=file>
--------------------------------
这是用ActiveX的方法了,如果用户做了这方面限制就没效果了。
--------------------------------
sendkey方法大致思路就和昨天想的用event.keyCode来模拟键盘输入差不多吧?只不过event.keyCode无法实现,而现在用windowscript来实现了
既然input type=file的value是只读,只能另想方法了,无论是outerHTML或者给value都是无效的