修改浏览按钮,chrome浏览器

发布于 2024-12-04 02:24:16 字数 550 浏览 4 评论 0原文

我制作了一个表单,用于上传图像,它在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

记忆消瘦 2024-12-11 02:24:16

请查看此处此处 (第二个答案)。文件类型的输入无法隐藏,通过设置 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 set visibility: hidden or you can play with opacity (like in the other answer).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文