Sealyu

--- 博客已迁移至: http://www.sealyu.com/blog

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  618 随笔 :: 87 文章 :: 225 评论 :: 0 Trackbacks

今天在做项目的时候,遇到上传文本框的问题,
<input type="file" size="100" name="photoupload" />
在firefox中,该控件产生的文本框是默认不可编辑的,但是在IE下,该文本框可编辑,
根据用户需要,此文本框应为不可编辑。
但是直接将其设置为“readonly”或者“disabled”后,对应的浏览按钮也无法使用了。所以此法不通。

在网上搜索了一些资料,主要有以下几种方法:
1.变通处理:
<input type=file id=a1 style="visibility:hidden">
<input id=a2 type=text readonly>
<input type=button value=浏览 onclick="a1.click(); a2.value= a1.value">
2.增加如下属性:
contenteditable="false"

 实例代码:

<input type="file" style="width: 446px" id="ptlFile" contenteditable="false"/>

对比一下,第二种简单方便,问题解决。

posted on 2008-09-28 11:08 seal 阅读(1020) 评论(1)  编辑  收藏 所属分类: web

评论

# re: 使input type="file" 不可编辑 2009-03-10 09:49 pass by
Thank you!  回复  更多评论
  


只有注册用户登录后才能发表评论。


网站导航: