You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
506 B
21 lines
506 B
2 years ago
|
var createUrl = require('./createUrl');
|
||
|
exports = function(data, name, type) {
|
||
|
type = type || 'text/plain';
|
||
|
var el = document.createElement('a');
|
||
|
el.setAttribute(
|
||
|
'href',
|
||
|
createUrl(data, {
|
||
|
type: type
|
||
|
})
|
||
|
);
|
||
|
el.setAttribute('download', name);
|
||
|
el.addEventListener('click', function(e) {
|
||
|
e.stopImmediatePropagation();
|
||
|
});
|
||
|
document.body.appendChild(el);
|
||
|
el.click();
|
||
|
document.body.removeChild(el);
|
||
|
};
|
||
|
|
||
|
module.exports = exports;
|