当前位置:网站首页>The download file of native JS implementation can be used anywhere
The download file of native JS implementation can be used anywhere
2022-07-29 00:29:00 【qiansli12138】
demand : Encapsulate a file download method , Call to use
function downLoadBlobFile (params) {
// export file
var url = "xxxxxx"; // Requested background address
var form = document.createElement("form");
form.id = "form";
form.name = "form";
document.body.appendChild(form);
for (var obj in params) {
if (!params[obj]) {
params[obj] = "";
}
if (params.hasOwnProperty(obj)) {
var input = document.createElement("input");
input.tpye = "hidden";
input.name = obj;
input.value = params[obj] ? params[obj] : "";
form.appendChild(input);
}
}
form.method = "POST"; // Request mode
form.action = url;
form.submit();
document.body.removeChild(form);
}When using, just pass in parameters :
var params = {
xxx: "xxxx",
xxx: "xxx",
url: "xxxxxx"
// See what you want at the back end Just pass it on to him
};
downLoadBlobFile(params)That's all. , Let's try
边栏推荐
- Visual full link log tracking
- Dynamic programming problem (6)
- 还在写大量 if 来判断?一个规则执行器干掉项目中所有的 if 判断...
- NPM replace the latest Taobao image
- 【MySQL 8】Generated Invisible Primary Keys(GIPK)
- Idea2021.2 installation and configuration (continuous update)
- 递归/回溯刷题(中)
- I don't know how lucky the boy who randomly typed the log is. There must be a lot of overtime!
- PTA (daily question) 7-74 yesterday
- vscode下链接远程服务器安装插件失败、速度慢等解决方法
猜你喜欢

Advanced area of attack and defense world web masters unserialize3

Laravel permission control

面试被问到了String相关的几道题,你能答上来吗?

vscode下链接远程服务器安装插件失败、速度慢等解决方法

The difference between {} and ${}

Web系统常见安全漏洞介绍及解决方案-sql注入

动态规划问题(六)

Advanced area of attack and defense world web masters ics-06

Kali installs burpsuite professional

vulnhub:Sar
随机推荐
【开发教程10】疯壳·开源蓝牙心率防水运动手环-蓝牙 BLE 收发
Redis learning notes
Api 接口优化有哪些技巧?
Immutable x officially opens IMX token pledge detailed IMX pledge introduction optimistic about the development prospect of IMX
IDEA2021.2安装与配置(持续更新)
Sword finger offer 55 - I. depth of binary tree
ACM SIGIR 2022 | interpretation of selected papers of meituan technical team
动态规划问题(六)
PTA (daily question) 7-77 encryption
110道 MySQL面试题及答案 (持续更新)
2022网络安全学习路线 非常详细 推荐学习
Applet verification code login
Eye of depth (18) -- partial derivative
flyway的快速入门教程
Feign call fails. JSON parse error illegal character ((ctrl-char, code 31)) only regular white space (R
Html+css+php+mysql realize registration + login + change password (with complete code)
面试被问到了String相关的几道题,你能答上来吗?
17.机器学习系统的设计
Concurrency in go
Detailed explanation of the usage of exists in MySQL