1
1
mirror of https://github.com/neosubhamoy/neosubhamoy-portfolio.git synced 2025-12-20 01:09:35 +05:30

(feat): added more sharing options with navigator.share api

This commit is contained in:
2023-11-26 23:42:55 +05:30
parent aa1ce2edde
commit c37380a358
3 changed files with 35 additions and 3 deletions

View File

@@ -331,3 +331,23 @@ shareBtn.addEventListener("click", function () {
shareCloseBtn.addEventListener("click", function () {
close_share();
});
function call_webshare_api() {
if(navigator.share) {
navigator.share({
title: document.getElementsByTagName("title")[0].innerHTML,
text: 'Check-out this awesome website:',
url: document.location.href
}).then(() => {
window.alert("Thanks for sharing!");
}).catch(console.error);
}
else {
if (window.location.protocol !== "https:") {
window.alert("Sorry, webShareAPI is not accessable as your connection with the server is not encrypted with https protocol");
}
else{
window.alert("Sorry, webShareAPI is not supported by your browser");
}
}
}