Problem with javascript function for iframe embed of data vis

Hi all, I have this iframe for a data vis on this page here: https://cmpf.eui.eu/mpm-2020-infographics-test-page/

Our developer told me to add the function below to the page to fix the height of the iframe.
I added it to custom fields but I am unsure of what I put in this “//h is the iframe content
//set iframe height on page”

I haven’t been able to contact him. Does it mean just add the iframe code and what code would I use to set the height?

Any help appreaciated.

<script type="text/javascript">
  window.addEventListener("message", function(event) {
    if(event.data.type == 'resize')
       refreshCmpfHeight(event.data.h);
  });

 function refreshCmpfHeight(h) {
   //h is the iframe content
   //set iframe height on page
   jQuery('iframe').height(h);
  }    
  </script>

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

Please use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks are not single quotes.

markdown_Forums