mirror of
https://github.com/kevinnlsamuel/rainbowcroissant.git
synced 2025-12-06 10:06:01 +05:30
make copy button work with iframed table
This commit is contained in:
@@ -14,9 +14,10 @@ desc: >
|
|||||||
<div>
|
<div>
|
||||||
<script type="module">
|
<script type="module">
|
||||||
const btn = document.getElementById('copybtn');
|
const btn = document.getElementById('copybtn');
|
||||||
|
const frame = document.querySelector('iframe').contentWindow;
|
||||||
btn.addEventListener("click", ()=> {
|
btn.addEventListener("click", ()=> {
|
||||||
window.getSelection().selectAllChildren(document.querySelector('article'));
|
frame.getSelection().selectAllChildren(frame.document.querySelector('table'));
|
||||||
document.execCommand('copy');
|
frame.document.execCommand('copy');
|
||||||
btn.innerText = 'COPIED!';
|
btn.innerText = 'COPIED!';
|
||||||
btn.disabled = true;
|
btn.disabled = true;
|
||||||
setTimeout(()=>{btn.disabled = false; btn.innerText = 'COPY'},3000)
|
setTimeout(()=>{btn.disabled = false; btn.innerText = 'COPY'},3000)
|
||||||
|
|||||||
Reference in New Issue
Block a user