我想祝福input type="file" (A),并在CSS中放置另一个按钮B。当我单击B时,我调用A.click()来浏览文件。
它在桌面网络浏览器中运行良好,比如IE8+、Google和Safari。然而,当Android应用程序插入webview时,click事件将不会被调用。(我在IOS应用程序中尝试了插入UIWebView,而且效果很好)。
我找到一篇文章,https://github.com/rogerwang/node-webkit/wiki/File-dialogs。它表明:
在
WebKit中,某些操作在javascript中是被禁止的,例如,您不能在<input type='file' />上生成一个单击事件,并且无法从它中设置/获取实际值。
既然webview in android是基于webkit的,那么如何正确地美化input type="file"呢?
发布于 2015-06-16 14:02:35
你可以用这样的东西
<label for="id_of_your_input">any html styles or text, just label tag</label>
<input type="file" id="id_of_your_input" name="name" style="display: none">它应起作用:)
你真的不能模拟点击输入文件,因为安全限制。
https://stackoverflow.com/questions/27613768
复制相似问题