1. 替代法
使用隱藏的<input type="file"/>控件,然后用一個只讀的文本框和一個按鈕來模擬<input type="file"/>的功能。
<inputtype="file"name="file"on2. 使用腳本事件限制控件輸入將<input type="file"/>控件的鼠標(biāo)右鍵菜單、按鍵事件限制住,不讓用戶有機(jī)會輸入。
<inputtype="file"onkeydown="returnfalse"onkeyup="returnfalse"oncontextmenu="returnfalse">3. 使用contenteditable屬性
使用該屬性可以有效地限制用戶在<input type="file"/>控件中手動輸入內(nèi)容,而只能通過文件選擇對話框選擇文件。
<inputtype="file"id="file1"contenteditable="false"/>新聞熱點
疑難解答