0

I'm trying to change style inside an iframe, I gave to the iframe the sandbox="allow-same-origin allow-scripts" attribute but I still get 'Blocked a frame with origin' what more can be the issue ?

<iframe
  height="100%"
  sandbox="allow-same-origin allow-scripts"
  src={formLink}
  onLoad={event => {
    console.log('event', event, event.target);
    const iframeEle = event.target;
    const iframeEleDocument = (iframeEle.contentWindow || iframeEle.contentDocument);
    console.log('iframeEleDocument', iframeEleDocument);
    debugger;
    iframeEleDocument.body.style.backgroundColor = "red";
  }}
/>
Bharata
  • 13,509
  • 6
  • 36
  • 50
greW
  • 1,248
  • 3
  • 24
  • 49

1 Answers1

0

I think thepostMessage is the security way to do that. You can set an event function in your iframe by using postMessage, and you can do what you wanna do there.

GitHub has many goods about the postMessage, and you can do it conveniently.

Simon.Lay
  • 263
  • 2
  • 9