make copy button work with iframed table

This commit is contained in:
2023-12-09 12:18:48 +05:30
parent 6ce84b0c5b
commit 0201cab985

View File

@@ -14,9 +14,10 @@ desc: >
<div>
<script type="module">
const btn = document.getElementById('copybtn');
const frame = document.querySelector('iframe').contentWindow;
btn.addEventListener("click", ()=> {
window.getSelection().selectAllChildren(document.querySelector('article'));
document.execCommand('copy');
frame.getSelection().selectAllChildren(frame.document.querySelector('table'));
frame.document.execCommand('copy');
btn.innerText = 'COPIED!';
btn.disabled = true;
setTimeout(()=>{btn.disabled = false; btn.innerText = 'COPY'},3000)