Content deleted Content added
Polygnotus (talk | contribs) No edit summary |
Polygnotus (talk | contribs) No edit summary |
||
Line 56:
textarea.value = text;
// Make the textarea
textarea.style.position = 'fixed';
textarea.style.
textarea.style.left = '10px';
textarea.style.width = '1px';
textarea.style.height = '1px';
textarea.style.padding = '0';
textarea.style.border = 'none';
textarea.style.outline = 'none';
textarea.style.boxShadow = 'none';
textarea.style.background = 'transparent';
textarea.style.zIndex = '999999';
document.body.appendChild(textarea);
//
textarea.select();
try {
//
if (success) {
resolve(true);
} else if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(text).then(() => {
document.body.removeChild(textarea);
resolve(true);
}).catch(err => {
// Fall back to document.execCommand▼
const success = document.execCommand('copy');▼
document.body.removeChild(textarea);
// Show the copy
visibleTextarea.value =
visibleTextarea.style.top = '50px';
visibleTextarea.style.left = '50px';
visibleTextarea.style.width = '80%';
visibleTextarea.style.height = '300px';
visibleTextarea.style.zIndex = '999999';
closeButton.textContent = 'Close';
closeButton.style.position = 'fixed';
closeButton.style.top = '360px';
closeButton.style.left = '50px';
closeButton.style.zIndex = '999999';
closeButton.onclick = () => {
document.body.removeChild(visibleTextarea);
};
document.body.appendChild(visibleTextarea);
document.body.appendChild(closeButton);
visibleTextarea.focus();
visibleTextarea.select();
resolve(true);
});
} else {
▲ // Use execCommand as fallback
▲ const success = document.execCommand('copy');
document.body.removeChild(textarea);
▲ resolve(true);
▲ } else {
▲ }
}
} catch (err) {
|