I have a site, containing only an image in the center of it. When somebody clicks it, image begins downloading to the user's computer. Recently, i've tried to launch it as Telegram Web App and there happend to be a problem. When i click the image on my pc (as TG WebApp) everything works properly, but when clicking it on my phone (sumsung a51) (as TG WebApp) nothing happens. Code of my site: HTML (only body):
<div class="wrapper">
<img class="image" src="pathtoimg" alt="img"></img>
</div>
<script src="https://telegram.org/js/telegram-web-app.js"></script>
<script src="./index.js"></script>
JS (index.js):
async function toDataURL(url) {
const blob = await fetch(url).then(res => res.blob());
return URL.createObjectURL(blob);
}
async function downloadFile(src, filename) {
const a = document.createElement("a");
a.href = await toDataURL(src);
a.download = filename;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
function main() {
const image = document.querySelector(".image")
if (image) {
image.addEventListener("click", (e) => {
downloadFile(image.src, "image.png")
})
}
}
main()
Thank to everybody trying to help me, i value it