Код: Выделить всё
//downloading als HTML file
var file = new window.Blob([document.documentElement.innerHTML], { type: "text/html" });
var URL = window.webkitURL || window.URL;
var downloadUrl = URL.createObjectURL(file);
var a = document.createElement("a");
a.download = "MyPage.html";
a.href = downloadUrl;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
< /code>
Я стараюсь реализовать возможность navigator.share (особенно на устройстве Android). Я попробовал следующий подход, к сожалению, без успеха: < /p>
//sharing via navigator
var file2 = new File([document.documentElement.innerHTML], { type: "text/html" });
var filesArray = [file2];
if (navigator.share) {
navigator.share({
title: "test",
file: filesArray,
})
.then(() => console.log('Successful share'))
.catch((error) => console.log('Error sharing', error));
}
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... ator-share
Мобильная версия