<div id="app">
<button type="button" id="share-button">Share</button>
</div>
const share = async (shareData) => {
try {
await navigator.share(shareData);
} catch (error) {
console.error(error);
}
};
const shareButton = document.querySelector("#share-button");
shareButton.addEventListener("click", () => {
let shareData = {
title: "you rock",
text: "Visit https://www.tocode.co.il to find great programming resources"
};
share(shareData);
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.