Clipboard - Web API | MDN (mozilla.org)
if (typeof navigator.clipboard === 'object') {
if (navigator.clipboard.readText(). === 'hoge'){
navigator.clipboard.writeText('hogehoge');
} else {
navigator.clipboard.writeText('hoge');
}
if (typeof navigator.clipboard === 'object') {
navigator.clipboard.writeText('hoge');
}
navigator.clipboard.readText()
.then((data) => console.log(data))
.catch((e) => console.error('failed'));
document.getElementById('btn').addEventListener('click', async () => {
const text = await navigator.clipboard.readText();
console.log(text);
});
async () => {
const text = await navigator.clipboard.readText();
console.log(text);
};
// IE
if (typeof window.clipboardData === 'object') {
window.clipboardData.setData('Text', value);