Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

173
Visualizações
iframe auto-resizing by id's

I'm having problems with auto resizing (height) of iFrames by id’s Is there a way to automatically generate the size of the iframe (height) based on the ids? The current code works, but unfortunately, it only captures the first iframe and I want to display the iframes based on the original height. Any suggestions, inputs, many thx. for all answers

Below the code, what I have tried:

<table width="100%" align="center" border="0">
    <tr><td valign="top" align="left">
        <table border="0">
            <tr><td align="center">
                <iframe id="menu" onLoad=" calchght();" src="./xxxxxx.html" scrolling="no" frameborder="0"></iframe>
            </td></tr>
        </table>
        </td>
        <td width="100%" valign="top">
        <iframe id="pageframe" onLoad=" calchght();" src="./xxxxxx.html" scrolling="no" frameborder="0"></iframe>   
    </td></tr>
</table>


<script language="JavaScript">
function calchght()
{
  //find the height of the page
  var heightframe=
    document.getElementById('pageframe').contentWindow.
      document.body.scrollHeight;

  //change the height of the iframe
  document.getElementById('pageframe').height= heightframe;
}
</script>


<script language="JavaScript">
function calchght()
{
  //find the height of the page
  var heightframe=
    document.getElementById('menu').contentWindow.
      document.body.scrollHeight;

  //change the height of the iframe
  document.getElementById('menu').height= heightframe;
}
</script>

Additional code, but this is checking all iframes not based on the id’s

  var framefenster = document.getElementsByTagName("iFrame");
  var auto_resize_timer = window.setInterval("autoresize_frames()", 400);
  function autoresize_frames() {
    for (var i = 0; i < framefenster.length; ++i) {
        if(framefenster[i].contentWindow.document.body){
          var framefenster_size = framefenster[i].contentWindow.document.body.offsetHeight;
          if(document.all && !window.opera) {
            framefenster_size = framefenster[i].contentWindow.document.body.scrollHeight;
          }
              framefenster_size = (framefenster_size+10);
          framefenster[i].style.height = framefenster_size + 'px';
        }
    }
  }
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda