This is my code:
var url = 'https://c4.wallpaperflare.com/wallpaper/203/636/834/minimalism-landscape-digital-windows-11-hd-wallpaper-preview.jpg';
function download(source) {
const fileName = source.split('/').pop();
var el = document.createElement("a");
el.setAttribute("href", source);
el.setAttribute("download", fileName);
document.body.appendChild(el);
el.click();
el.remove();
}
download(url);
When I call this function it’s open the image instead of download it can anyone please tell me why it’s happening what’s wrong with my code…