IE(IE8以及一下)浏览器下模拟键盘操作,js 给 input type=file赋值
<html>
<head>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页</title>
<style type="text/css">
body{
}
</style>
</head>
<body>
<input type="file" id="fileInput" value=""><br>
模拟键盘操作文件上传控件<input type="button" value="写入" onclick="f('C:\\exam\\');">
<script language="javascript">
function f(txt){
var file_input_obj = ElementById("fileInput");
file_input_obj.focus();
var WshShell=new ActiveXObject("WScript.Shell");
WshShell.SendKeys("{Tab}");
WshShell.SendKeys("{ }");
WshShell.SendKeys(txt);
WshShell.SendKeys("{Enter}");
inputtypefile不上传文件
}
</script> 
</body>
</html>

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。