Spaces:
Sleeping
Sleeping
File size: 1,055 Bytes
65a422d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
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';
}
|