-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshare.js
19 lines (17 loc) · 952 Bytes
/
share.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
document.getElementById('twitterShare').addEventListener('click', () => {
const shareUrl = `https://twitter.com/intent/tweet?url=${encodeURIComponent(document.location.href)}&text=${encodeURIComponent('ありがとうを伝えよう。')}`;
window.open(shareUrl, '_blank');
});
document.getElementById('lineShare').addEventListener('click', () => {
const shareUrl = `https://line.me/R/msg/text/?${encodeURIComponent(document.location.href)}`;
window.open(shareUrl, '_blank');
});
document.getElementById('copyUrl').addEventListener('click', () => {
navigator.clipboard.writeText(document.location.href).then(() => {
console.log('URLがクリップボードにコピーされました。');
alert('URLがクリップボードにコピーされました。');
}).catch(err => {
console.error('URLをクリップボードにコピーできませんでした。', err);
alert('エラー')
});
});