有什么方法可以在使用data:URI时指定建议的文件名? [英] Is there any way to specify a suggested filename when using data: URI?

查看:110
本文介绍了有什么方法可以在使用data:URI时指定建议的文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,您可以按照以下链接进行操作:

data:application / octet-stream; base64,SGVsbG8 =



浏览器会提示您下载超链接本身包含base64数据的文件。有没有什么方法在标记中建议默认名称?如果没有,是否有JavaScript解决方案?

使用下载解决方案

属性:

 < a download ='FileName'href ='your_url'> 

现场示例 html5-demos.appspot.com / ...



目前适用于Chrome,Firefox,Edge,Opera,但不适用于Safari 10或IE11。


If for example you follow the link:

data:application/octet-stream;base64,SGVsbG8=

The browser will prompt you to download a file consisting of the data held as base64 in the hyperlink itself. Is there any way of suggesting a default name in the markup? If not, is there a JavaScript solution?

解决方案

Use the download attribute:

<a download='FileName' href='your_url'>

Live example on html5-demos.appspot.com/....

Currently works on Chrome, Firefox, Edge, Opera, but not Safari 10 or IE11.

这篇关于有什么方法可以在使用data:URI时指定建议的文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆