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

283
Views
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
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!