html5 href下载属性不适用于.pdf文件 [英] html5 href download attribute not working with .pdf file
问题描述
当用户单击表格元素中的图像时,我希望下载.pdf文件.这就是我所拥有的:
I want a .pdf file to download when the user clicks on an image within a table element. This is what I've got:
< a href ="splosion_CV.pdf" download ="splosion_CV.pdf">< img src ="images/downloadIcons/download_icon_violet.png" width ="32" height ="32" alt=下载我的简历" border ="0"/></a>
现在,它似乎可以单击下载,但是Chrome会显示服务器故障".我使用的是Chrome版本38,但广告屏蔽扩展程序已关闭.
Right now, it appears to download on click, but then Chrome says "failed-server problem". I'm using Chrome version 38, with the ad-block extension turned off.
.pdf位于我的public_html文件夹中(不在任何子文件夹中),因此文件路径似乎正确...
The .pdf is in my public_html folder (not in any subfolder)so the file-path seems right...
当我尝试从Safari 7.0.6中的链接下载时,出现以下消息:禁止.您无权访问此服务器上的/splosion_CV.pdf.此外,尝试时遇到404 Not Found错误使用ErrorDocument处理请求."
When I try downloading from the link in Safari 7.0.6 I get this message: "Forbidden. You don't have permission to access /splosion_CV.pdf on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."
有人知道为什么download属性对我不起作用吗?
Any idea why the download attribute isn't working for me?
推荐答案
我在chrome&火狐,看起来很完美.
i run your code in chrome & fire-fox and looks like its works perfectly.
代码是:
<!DOCTYPE html>
<html>
<body>
<a href="hello.pdf" download>
<img src="Cube.png" width="32" height="32" border="0"/>
</a>
</body>
</html>
注意:IE,Safari或Opera版本12不支持下载属性.
(及更早版本)
Note: The download attribute is not supported in IE, Safari or Opera version 12
(and earlier)
这篇关于html5 href下载属性不适用于.pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!