input file 问题

shao1986 2008-06-30 04:54:59
如何将INPUT FILE 只能点击添加文件,不可手动修改他。。
...全文
87 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
skyearthsea 2008-07-01
  • 打赏
  • 举报
回复
5楼的把 contenteditable="false" 去掉不好使
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 skyearthsea 的回复:]
4楼 好办法
[/Quote]
在ie下确实很好用但firefox是不认ocument.getElementById('browseFile').click()这种用法的
skyearthsea 2008-07-01
  • 打赏
  • 举报
回复
4楼 好办法
  • 打赏
  • 举报
回复
用div把他蒙住
<html>
<head>
<title>file只读</title>
<script type="text/javascript">
var $=function(strId){
return document.getElementById(strId);
}
</script>
</head>
<body>
<input type="file" id="file1" contenteditable="false"/>
<div id="divMask" style="position:absolute;border:1px solid red;"></div>
<script>
var oFile=$("file1");
var oDiv=$("divMask");
oDiv.style.left=oFile.offsetLeft;
oDiv.style.top=oFile.offsetTop;
oDiv.style.width=oFile.offsetWidth-70;
oDiv.style.height=oFile.offsetHeight;
</script>
</body>
</html>
阿云ivan 2008-06-30
  • 打赏
  • 举报
回复
<input id="selectedFile" type="text" readonly="readonly" value="" /><input type="button" value="浏览..." id="Button1" onclick="document.getElementById('browseFile').click()" />
<input id="browseFile" type="file" style="display:none;" onchange="document.getElementById('selectedFile').value=this.value;" />
shao1986 2008-06-30
  • 打赏
  • 举报
回复
不上啊 楼上的 只针对IE可以 FRIEFOX不行
西安风影 2008-06-30
  • 打赏
  • 举报
回复
<input type="file" id="FilePath" name="FilePath" contenteditable="false" />

87,903

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧