MozTW 討論區

各項 Mozilla 相關軟體與技術討論
現在的時間是 2025-06-27, 00:52

所有顯示的時間為 UTC + 8 小時





發表新文章 回覆主題  [ 5 篇文章 ] 
發表人 內容
文章發表於 : 2004-10-18, 23:27 
離線

註冊時間: 2004-10-18, 22:59
文章: 21
先附上程式碼,如下:
代碼:
<html>
<head>
<title>xyz</title>
<head>

<script Language="JavaScript">
function openfile(){
   document.getElementById("ifile").click();
}
</script>

<style type="text/css">
.class11{color:#0000FF;cursor:pointer;}
</style>

<body>
<form name="frm1" action="nexturl.php" method="post">
<input type="file" id="ifile" style="display:none">
<u class="class11" onclick="openfile();">click here to select a file</u>
<input type="submit" value="submit">
</form>
</body>
</html>


我想要用一串文字(或用圖片)來作出實際點擊FileUpload Tag的效果
上面那串code在IE下運作正常,但是在FireFox卻毫無反應
請問一下究竟是程式碼有問題呢?還是FireFox根本不支援FileUpload.click()?

先謝謝各位前輩...


回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.0; rv:1.7.3) Gecko/20040913 Firefox/0.10.1
 個人資料  
引用回覆  
 文章主題 :
文章發表於 : 2004-10-19, 01:25 
離線

註冊時間: 2004-06-23, 12:28
文章: 232
你的 form 標籤應該宣告為 enctype="multipart/form-data"
另外, 你可使用 document.fm1.submit();


回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)
 個人資料  
引用回覆  
 文章主題 :
文章發表於 : 2004-10-20, 20:12 
離線

註冊時間: 2004-10-18, 22:59
文章: 21
member 寫:
你的 form 標籤應該宣告為 enctype="multipart/form-data"
另外, 你可使用 document.fm1.submit();

謝謝你的回答
post時不知道在想什麼,忘了加上enctype宣告 :oops:
不過重點是下面這行script無法執行
代碼:
document.getElementById("ifile").click();

不知道這是不是只有IE才能執行?


回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.7) Gecko/20040626 Firefox/0.9.1
 個人資料  
引用回覆  
 文章主題 :
文章發表於 : 2006-03-29, 14:51 
是的,mozilla和Opera均不支持click()方法

The click() method allows you to simulate a click on a form field. Checkboxes get toggled, radios selected, and so on. Unfortunately Mozilla and Opera haven't added this method to file upload fields. I wonder why, adding it is not really a security risk since the worst that can happen is that the file selection window pops up.

So unfortunately we cannot use this simple solution


回頂端
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon)
  
引用回覆  
 文章主題 :
文章發表於 : 2006-03-30, 22:13 
離線
[網站管理員]
頭像

註冊時間: 2004-09-27, 09:24
文章: 1685
這就是為什麼在 Gmail 中,按 Add attachment,IE 會跳出瀏覽檔案的對話方塊,在 Firefox 中就得自己按[瀏覽]

_________________
korp + korp 中文站(沒精神更新)


回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1
 個人資料  
引用回覆  
顯示文章 :  排序  
發表新文章 回覆主題  [ 5 篇文章 ] 

所有顯示的時間為 UTC + 8 小時


誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 3 位訪客


不能 在這個版面發表主題
不能 在這個版面回覆主題
不能 在這個版面編輯您的文章
不能 在這個版面刪除您的文章
不能 在這個版面上傳附加檔案

搜尋:
前往 :  
Powered by phpBB® Forum Software © phpBB Group
正體中文語系由 竹貓星球 維護製作
© moztw.org, Mozilla Foundation
MozTW,Mozilla 台灣社群