歡迎您光臨本站 註冊首頁

使input type=

←手機掃碼閱讀     火星人 @ 2014-03-09 , reply:0

  今天在做項目的時候,遇到上傳文本框的問題,

  <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"/>

  對比一下,第二種簡單方便,問題解決.


[火星人 ] 使input type=已經有312次圍觀

http://coctec.com/docs/java/show-post-60709.html