长话短说,我需要能够阻止input type="file". 换句话说,当用户单击“浏览”或“选择文件”时,我不想显示系统打开的对话框。我已经可以使用替换对话框,但系统的打开对话框仍然出现。
以下是我目前正在尝试实现此目标的示例。(PS:我使用的是Chrome 21)
<html>
<head>
<script type="text/javascript">
<!--
file_onclick = function()
{
// Show custom dialog instead...
event.stopPropagation(); // Doesn't work
return false; // Neither does this
};
//-->
</script>
</head>
<body>
<input type="file" onclick="javascript: file_onclick();" />
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?