Ugh, been there. The errors usually mean it's cross-origin, and browsers block access iframe from parent element for security.
If you *do* control both pages, `postMessage` is your best bet. Here's a quick example:
Parent:
```js
iframe.contentWindow.postMessage('hello', 'https://iframe-origin.com');
```
Iframe:
```js
window.addEventListener('message', (e) => {
if (e.origin === 'https://parent-origin.com') {
console.log(e.data); // 'hello'
}
});
```
No hacks for cross-origin tho—just how the web works now.
If you *do* control both pages, `postMessage` is your best bet. Here's a quick example:
Parent:
```js
iframe.contentWindow.postMessage('hello', 'https://iframe-origin.com');
```
Iframe:
```js
window.addEventListener('message', (e) => {
if (e.origin === 'https://parent-origin.com') {
console.log(e.data); // 'hello'
}
});
```
No hacks for cross-origin tho—just how the web works now.
