Loading...

點選檔案下載卻直接執行開啟

Temperature: 0 °C

Mark ChangMark Chang
author_tools

遇到一個情況。

使用者開啟瀏覽器點選某個連結檔案時,不會執行下載而是直接開啟檔案。

原本如果只是圖片或是PDF檔案來說原則上是沒有問題,因為瀏覽器也可以支援開啟

但如果是RAR或者是ZIP又或者是一些瀏覽器無法識別的檔案直接開起就有可能會造成顯示亂碼的問題。

其實只需要加上一個download的屬性就可以解決。

如下範例:

<a href="路徑" download="filename.rar">點選下載</a>

以上紀錄~

#故事  #download  #造成顯示亂碼  
https://innstory.com/story-點選檔案下載卻直接執行開啟-2788
html5

Prev
 青少年

Next
如何將_a_href_禁用 

About the Author

Mark Chang

離不開電腦的宅男

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

當域名 DNS 尚未生效時,如何預先設定及測試網站

當域名 DNS 尚未生效時,...

建置一個新的網站或是將網站搬家時 常常會遇到一個問題,就是要將網址指向到新的網站空間,設定完畢但需要...

使用CSS讓Youtube自動適應寬度跟高度

使用CSS讓Youtube自...

pexelsphotomedia 在播放Youtube影音的時候,常使用 iframe 的方式崁入網...

Android Fragment及Activity 中使用sharedpreferences

Android Fragme...

在Android下想要儲存執行資料的方式有好幾種,例如存在手機空間或者是資料庫空間。 這裡紀錄一下使...

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format