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

288
Vistas
React / Nextjs page as an iframe on another page with resizing

I am trying to embed my nextjs / react website inside a wordpress site. That works so far, but it does not size the iframe properly.

I found a solution, which is for native js, which I need to add to my react app

  function sendHeight() {
    if (parent.postMessage) {
      // replace #wrapper with element that contains 
      // actual page content
      var height = document.getElementById('calendar-wrapper').offsetHeight;
      parent.postMessage(height, '*');
    }
  }

  // Create browser compatible event handler.
  var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
  var eventer = window[eventMethod];
  var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";

  // Listen for a message from the iframe.
  eventer(messageEvent, function (e) {

    if (isNaN(e.data)) return;

    sendHeight();

  }, false);

The question which I have is how can I run this properly in my functional component?

For instance if the functional component looks like this:

const Home = () => {
    return (
        <div id="calendar-wrapper">
    ...
}

I am not sure when to call the eventer in the react way.

about 4 years ago · Juan Pablo Isaza
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