大魚

          使input type="file" 不可編輯

          使input type="file" 不可編輯
          今天在做項(xiàng)目的時(shí)候,遇到上傳文本框的問(wèn)題,
          <input type="file" size="100" name="photoupload" />
          在firefox中,該控件產(chǎn)生的文本框是默認(rèn)不可編輯的,但是在IE下,該文本框可編輯,
          根據(jù)用戶需要,此文本框應(yīng)為不可編輯。
          但是直接將其設(shè)置為“readonly”或者“disabled”后,對(duì)應(yīng)的瀏覽按鈕也無(wú)法使用了。所以此法不通。

          在網(wǎng)上搜索了一些資料,主要有以下幾種方法:
          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"

           實(shí)例代碼:

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

          對(duì)比一下,第二種簡(jiǎn)單方便,問(wèn)題解決。

          posted on 2009-03-13 23:25 大魚 閱讀(697) 評(píng)論(1)  編輯  收藏 所屬分類: javascript

          評(píng)論

          # re: 使input type="file" 不可編輯 2010-08-07 13:28 龍心

          thank you very much!  回復(fù)  更多評(píng)論   

          主站蜘蛛池模板: 烟台市| 长葛市| 永寿县| 佳木斯市| 龙门县| 凤城市| 汕尾市| 青铜峡市| 建德市| 怀宁县| 普安县| 和政县| 大同市| 六安市| 广东省| 周至县| 天祝| 措勤县| 靖远县| 彰武县| 房产| 伊宁市| 仪陇县| 吐鲁番市| 桂阳县| 澄迈县| 瑞安市| 文山县| 临猗县| 台东县| 罗田县| 霍山县| 尚义县| 榆中县| 新田县| 类乌齐县| 卫辉市| 察隅县| 祁连县| 龙井市| 平湖市|