修改浏览按钮,chrome浏览器
我制作了一个表单,用于上传图像,它在 IE、Firefox 上运行良好。 但在 chrome 上浏览按钮不起作用。
这是浏览按钮:
<input type="button" name="brw" id="brw" onClick="img.click()" />
当您单击此按钮时,您将启动 img 字段浏览功能。
其他字段:
<input name="img" type="file" value="" style="display: none;" onChange="txtFilename.value = this.value;" />
当您选择图像时,您会在此禁用的文本字段中获得图像名称。
<input type="text" name="txtFilename" id="txtFilename" disabled="disabled" />
任何跨浏览器的解决方案都可以挽救我的生命:)。 谢谢大家。
I've made a form, for uploading an image, it works good on IE,Firefox.
But on chrome the browse button doesn't work.
This is the browse button:
<input type="button" name="brw" id="brw" onClick="img.click()" />
When you click this button you fire up img fields browse function.
Other fields:
<input name="img" type="file" value="" style="display: none;" onChange="txtFilename.value = this.value;" />
And when you select the image you get images name in this disabled text field.
<input type="text" name="txtFilename" id="txtFilename" disabled="disabled" />
Any solution for crossbrowser, would save my life :) .
Thx all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请查看此处和此处 (第二个答案)。文件类型的输入无法隐藏,通过设置
display: none
必须以其他方式隐藏它。在我的示例中,我设置了visibility:hidden
或者您可以使用不透明度(就像在其他答案中一样)。Look here and here (second answer). Input of file type cannot be hidden, by setting
display: none
you have to hide it in another way. In my example I setvisibility: hidden
or you can play with opacity (like in the other answer).