如何将浏览按钮重命名为“ 选择文件 ”?例如:
<input type=file name=browse >
发布于 2019-04-15 11:46:23
该按钮不称为“浏览按钮” - 这只是您的浏览器为其提供的名称。浏览器可以自由地实现文件上传控制,但是他们喜欢。例如,在Safari中,它被称为“选择文件”,它与你可能使用的任何东西相反。
您可以使用QuirksMode上概述的技术实现上传控件的自定义外观,但这不仅仅是更改按钮的文本。
发布于 2019-04-15 13:14:23
一点JavaScript:
<script language="JavaScript" type="text/javascript">
function HandleBrowseClick()
{
var fileinput = document.getElementById("browse");
fileinput.click();
var textinput = document.getElementById("filename");
textinput.value = fileinput.value;
}
</script>
<input type="file" id="browse" name="fileupload" style="display: none"/>
<input type="text" id="filename" readonly="true"/>
<input type="button" value="Click to select file" id="fakeBrowse" onclick="HandleBrowseClick();"/>
不是最美观的解决方案,但它能执行。
https://stackoverflow.com/questions/-100001409
复制相似问题