Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

234
Views
iframe resize cause flickering when using different origin

I need an advise on how to avoid iframe from flickering when resize. I wanted to display bubble components within iframe when iframe is hovered. To display the bubble component, I would need to resize the iframe container.

The iframe source was built using react framework. So to pass the state change from iframe component to parent window, I'm doing it like this:

const onMouseOver = useCallback(() => {
  window.parent.postMessage({ isBubble: true }, '*');
}, [])

and in parent window, I'm listening to the state change like this:

// append iframe to parent window body
var iframe = document.createElement('iframe');
iframe.src = <source to my react web app>
iframe.style.width = '20px';
iframe.style.height = '20px';
document.body.appendChild(iframe);

// listen to message
window.addEventListener('message', resizeIframe)

//resize iframe method
function resizeIframe(e) {
 var data = e.data

 // change iframe size 
 if (data.isBubble) {
  iframe.style.width = '100px';
  iframe.style.height = '100px';
 }
}

At first, I thought the flickering issue is because of iframe is not loaded properly.

I have tried all of the solution mentioned in how to fix chrome flicker on iframe page reload. But none of it is working.

I'm suspecting the flickering issue comes only when resize, cause when I used static iframe size, the bubble components popup properly without any issue.

edit: I found out the flickering issue happen only when i'm pointing iframe to different origin. Example <iframe src="https://different origin"></iframe> but working fine if it is using same origin

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can try using this library

iframe-resizer-react

you can find it here: https://www.npmjs.com/package/iframe-resizer-react

it should help with the problem that you are facing

Hope this helps!

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!