Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
267 views
in Technique[技术] by (71.8m points)

javascript - 使用数据时,有什么方法可以指定建议的文件名:URI?(Is there any way to specify a suggested filename when using data: URI?)

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.(浏览器将提示您下载一个文件,该文件包含超链接本身中保存为base64的数据。) Is there any way of suggesting a default name in the markup?(有什么办法可以建议标记中的默认名称吗?) If not, is there a JavaScript solution?(如果没有,是否有JavaScript解决方案?)   ask by translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Use the download attribute:(使用download属性:)

<a download='FileName' href='your_url'> Live example on html5-demos.appspot.com/... .(html5-demos.appspot.com / ...上的实时示例。) Currently works on Chrome, Firefox, Edge, Opera, and desktop Safari but not iOS Safari or IE11.(目前可在 Chrome,Firefox,Edge,Opera和桌面Safari上运行,但不适用于iOS Safari或IE11。)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...