2014-07-24 238 views
1

我需要根据JSP中的区域设置更改“浏览”按钮文本。 (例如俄语,葡萄牙语)为Spring为基础的项目。如何更改“浏览”按钮文本

以下为浏览按钮

<td><input type="file" id="file" name="fileName"/></td> 

enter image description here

目前执行正如我知道我们不能改变输入类型的文件文本。这是浏览器中浏览按钮的默认行为。

我尝试以下解决方案

<input type="button" id="button" value="Browse"/> 
<input type="file" id="fileName" style="opacity:0; position:relative; left:-40px;" onchange="javascript: document.getElementById ('fileName').value = this.value"/> 

enter image description here

但上面一个是给安全问题在浏览器中。

enter image description here

<input type="file" name="filename" id="filename-input" value="browse" size="18" style="float: right; width: 250px;"> 

谁能帮我解决此问题:


https://stackoverflow.com/它(使用输入型文件改变文本的浏览按钮),具有这种理想的解决方案问题或实现上述解决方案的方式(https://stackoverflow.com/文件上传)。

+0

它给什么样的安全问题? – Jaiwo99

+0

[如何更改?](https://stackoverflow.com/questions/1944267/how-to-change-the-button-text-of-输入型文件) – Bae

回答

0

建议你去做这种方式来保持它的简单:

<input type="file" style="display:none"/> 
<button id="browse">whatever</button> 

$('#browse').click(function(){ 
    $('input[type="file"]').trigger('click'); 
}); 
相关问题