当前位置:网站首页>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
边栏推荐
- 2022DASCTF7月赋能赛(复现)
- What does the expression > > 0 in JS mean
- Attack and defense world web master advanced area web_ php_ unserialize
- Recursion / backtracking (middle)
- 110道 MySQL面试题及答案 (持续更新)
- 手把手教你安装Latex(保姆级教程)
- NPM replace the latest Taobao image
- Advanced area of attack and defense world web masters training www robots
- [CNN] Why is the convolution kernel size of CNN usually odd
- pnpm的安装与使用
猜你喜欢

Samsung asset management (Hong Kong) launched yuancosmos ETF to focus on investing in the future tuyere track

MQ 消息丢失、重复、积压问题,如何解决?

Api 接口优化有哪些技巧?

Using recursion and chain header interpolation to realize the group turnover of linked lists -- leetcode25 K group turnover linked lists

Statistical analysis of time series

Advanced area of attack and defense world web masters training www robots

NFTScan 与 NFTPlay 在 NFT 数据领域达成战略合作

时间序列统计分析

MySQL的存储过程

PTA (daily question) 7-69 narcissus number
随机推荐
Feign call fails. JSON parse error illegal character ((ctrl-char, code 31)) only regular white space (R
How to solve the problems of MQ message loss, duplication and backlog?
@Detailed explanation of postconstruct annotation
动态规划问题(一)
PTA (daily question) 7-74 yesterday
#{}和${}的区别
@Transactional 注解使用详解
Google browser, no installation required
2022 network security learning route is very detailed, recommended Learning
NPM run serve stuck at 40%
Dynamic programming (V)
[development tutorial 10] crazy shell · open source Bluetooth heart rate waterproof sports Bracelet - Bluetooth ble transceiver
@PostConstruct注解详解
Dynamic programming problem (1)
CV target detection model sketch (2)
Compilation principle research study topic 2 -- recursive descent syntax analysis design principle and Implementation
Detailed explanation of the usage of exists in MySQL
1331. 数组序号转换 : 简单模拟题
17.机器学习系统的设计
vulnhub:BTRSys2