Решение, как в мобильной версии сайта, если нажать кнопку поделиться, откроется выбор приложений которые есть на смартфоне. Для телефонов на Android и iOS

Решение:
HTML
JS
<button class="share">Поделиться</button>
JS
const shareButton = document.querySelector('.share'),
thisUrl = window.location.href,
thisTitle = document.title;
shareButton.addEventListener('click', event => {
if (navigator.share) {
navigator.share({
title: thisTitle,
url: thisUrl
}).then(() => {
alert('Thanks for sharing!');
})
.catch(console.error);
} else {
alert('Web Share API не поддерживается');
}
});_ Похожие решения:
Комментарии (0)