hermit-V2/assets/js/link-share.js

7 lines
418 B
JavaScript
Raw Permalink Normal View History

2023-11-06 03:18:30 -05:00
async function linkShare(t, u, s){
2023-11-06 03:26:39 -05:00
let shd = {title: t,text: s,url: u};
2023-11-06 03:46:57 -05:00
if(typeof navigator.canShare === "function" && navigator.canShare(shd)){
2023-11-06 03:26:39 -05:00
try {await navigator.share(shd);} catch (er) {console.error(er);}
2023-11-06 03:18:30 -05:00
}else if (navigator?.clipboard?.writeText){
try {await navigator.clipboard.writeText(u);} catch (err) {console.error(err);}
}else{console.log("Neither WebShare API nor CLipboard API is supported")}}