问题描述
我生成正常链接,如:< a href =/ path / to / image>< img src =/ path / to / image/>< / a> ;
在网络应用程序中。
当我点击链接时,它会在新页面中显示图片。如果要保存图片,则需要右键单击并选择另存为
我不想要这个行为,我想要当我点击链接时,一个下载框弹出,是可能只是用html或javascript?如何?如果不是,我想我将不得不编写一个download.php脚本并将其称为href文件名作为参数??
< a download =custom-filename.jpghref =/ path / to / imagetitle =ImageName>
< img alt =ImageNamesrc =/ path / to / image>
< / a>
尚未完全支持 ,但您可以使用modernizr (在非核心检测)来检查浏览器的支持。
I generate normal links like: <a href="/path/to/image"><img src="/path/to/image" /></a>
in a web app.
When I click on the link, it displays the picture in a new page. If you want to save the picture, then you need to right click on it and select "save as"
I don't want this behaviour, I would like to have a download box popping out when I click on the link, is that possible just with html or javascript? How?
If not I guess I would have to write a download.php script and call it into the href with the file name as parameter...?
<a download="custom-filename.jpg" href="/path/to/image" title="ImageName">
<img alt="ImageName" src="/path/to/image">
</a>
It's not yet fully supported http://caniuse.com/#feat=download, but you can use with modernizr https://modernizr.com/download/?adownload-setclasses (under Non-core detects) to check the support of the browser.
这篇关于href图像链接下载点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!