如何下载文件而不使用< a>元素与下载属性或服务器? [英] How to download a file without using <a> element with download attribute or a server?

查看:94
本文介绍了如何下载文件而不使用< a>元素与下载属性或服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 caniuse 下载 的TR / html5 / links.html#downloads-resources =nofollow c $ c> href =https://developer.microsoft.com/en-us/microsoft-edge/platform/status/adownloadattribute =nofollow> Microsoft Edge build 10547+ ,但不是IE或Safari

According to caniuse the download attribute of <a> element is supported at Microsoft Edge build 10547+, but not IE or Safari.

如果不使用< a> 元素下载文件对象,而$ 下载属性集或服务器?

How to download a file object without using <a> element with download attribute set or a server?

推荐答案

有多种触发下载方式。以下是一些:

There are a number of ways of triggering a download. Here are a few:

使用表单

<form method="get" action="mydoc.doc">
<button type="submit">Download</button>
</form>

使用javascript:

<button type="submit" onclick="window.open('mydoc.doc')">Download</button>

这篇关于如何下载文件而不使用&lt; a&gt;元素与下载属性或服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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