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

7 lines
374 B
JavaScript
Raw 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};
if(navigator.canShare(shd)){
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")}}