Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

229
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda