Spaces:
Running
Running
| function createIframeHandler() { | |
| let iframe = document.getElementById('link-frame'); | |
| if (!iframe) { | |
| iframe = document.createElement('iframe'); | |
| iframe.id = 'link-frame'; | |
| iframe.style.position = 'absolute'; | |
| iframe.style.width = '1px'; | |
| iframe.style.height = '1px'; | |
| iframe.style.right = '-100px'; | |
| iframe.style.bottom = '-100px'; | |
| iframe.style.display = 'none'; // Hidden initially | |
| document.body.appendChild(iframe); | |
| } | |
| document.addEventListener('click', function (event) { | |
| var link = event.target.closest('a'); | |
| if (link && link.href) { | |
| try { | |
| iframe.src = link.href; | |
| iframe.style.display = 'block'; // Show iframe on link click | |
| event.preventDefault(); | |
| console.log('Opening link in iframe:', link.href); | |
| } catch (error) { | |
| console.error('Failed to open link in iframe:', error); | |
| } | |
| } | |
| }); | |
| return 'Iframe handler initialized'; | |
| } | |