小编vbg*_*yny的帖子

防止 html 输入类型文件显示打开的对话框

长话短说,我需要能够阻止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)

有任何想法吗?

html javascript input-type-file

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

html ×1

input-type-file ×1

javascript ×1