Spaces:
Running
Running
File size: 735 Bytes
b9fe2dd |
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 |
// Listen for 'focus' message from the parent window
window.addEventListener('message', function (event) {
if (event.data === 'focus') {
// Find the textarea element
const textarea = document.querySelector('textarea');
console.log('focusing on textarea', textarea);
// If the textarea is found, focus on it
if (textarea) {
textarea.focus();
} else {
console.warn('Textarea not found for focus');
}
}
});
window.addEventListener('keydown', function (event) {
if (event.key === 'Escape') {
if (document.activeElement) {
document.activeElement.blur();
}
// Send a message to the parent window to close this iframe
window.parent.postMessage('closeDocbot', '*');
}
});
|