답변 2개
채택된 답변
+20 포인트
RYANRYAN
1년 전
참고하세요. 디버깅은 안했습니다.
Copy
<a href="#" onclick="share_page('페이지제목','https://주소');" >공유</a>
<script>
function share_page(val1, val2) {
if(navigator.share){
navigator.share({
title: val1,
url: val2
}).then(() => {
console.log('sharing success');
})
.catch(console.error);
}else{
var t = document.createElement("textarea");
document.body.appendChild(t);
t.value = val2;
t.select();
document.execCommand('copy');
document.body.removeChild(t);
alert('주소가 클립보드에 복사되었습니다.');
console.log('copy success');
}
}
</script>
로그인 후 평가할 수 있습니다
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
답변에 대한 댓글 3개
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
