You can not trigger a file dialog from JavaScript in Opera. I'm somewhat surprised if other browsers allow this..
It is still possible to do what you want by placing an invisible file input on top of your text link. To make it invisible, you can for example style it with opacity:0. This way, the users will get the impression that they are clicking a text link while the click will actually hit the file input and trigger the file dialog.
发布评论
评论(2)
似乎由于安全策略触发了某些浏览器中不允许/支持点击输入 type=
file
的情况,opera 是其中之一,请参阅此答案Opera 中的输入类型文件
it seems like due to security policies triggering click on the input type=
file
is not allowed/supported in some browsers and opera is one of themsee this answer input type file in Opera
您无法在 Opera 中从 JavaScript 触发文件对话框。如果其他浏览器允许这样做,我会感到有些惊讶。
仍然可以通过在文本链接顶部放置一个不可见的文件输入来完成您想要的操作。要使其不可见,您可以使用
opacity:0
对其进行样式设置。这样,用户会觉得他们正在单击文本链接,而单击实际上会点击文件输入并触发文件对话框。You can not trigger a file dialog from JavaScript in Opera. I'm somewhat surprised if other browsers allow this..
It is still possible to do what you want by placing an invisible file input on top of your text link. To make it invisible, you can for example style it with
opacity:0
. This way, the users will get the impression that they are clicking a text link while the click will actually hit the file input and trigger the file dialog.