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.
20 lines
506 B
20 lines
506 B
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;
|
|
|