推 mrbigmouth:window.open要下載的網址 server端做處理 response 06/01 15:22
→ mrbigmouth:header 標註正確 瀏覽器就會自動開起下載 06/01 15:22
→ wind681201:因為會傳值回去,window.open只能用get方式,要用post 06/01 18:10
→ wind681201:有看到可以post方式,但這樣會換頁,我希望不要換頁 06/01 18:33
推 mrbigmouth:建一個form method用post target用_blank然後submit 06/01 19:03
→ mrbigmouth:其實直接指location.href就行了 如果content-type是 06/01 19:05
→ mrbigmouth:下載的話我記得是不會換頁的 06/01 19:05
→ mrbigmouth:喔要post的話還是得靠form 06/01 19:05
→ mrbigmouth:總之想靠javascript直接寫檔案是行不通的 安全性問題 06/01 19:06
→ wind681201:我目前是用target=_blank的方式,連結的話,還是會換頁 06/01 20:48
推 Peruheru:我是弄一個隱藏的iframe,然後form的target指向他 07/22 11:55
→ Peruheru:把要post資料submit出去之後,只要接收端呈現的是檔案 07/22 11:56
→ Peruheru:就會自動下載了 07/22 11:56