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

120
Visualizações
Hide iframe if height is 150px

I have an iframe which is loading external content dynamically from a site I have control of.

In case no content is available I load an empty page.

Unfortunately an iframe has a height of 150px.

How can I at best with Javascript define to hide the mother div (container) or iframe in case the iframe has the standard size of 150px?

<div id="container">

<iframe src=""> </iframe>

</div>
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can use the client.Height to get the Height of an element (with padding, the border is not included)

Try this:

const iframe = document.querySelector('iframe');
let iframeHeight = iframe.clientHeight;

if (iframeHeight == 150) {
    iframe.style.display = "none";
}

It will be hide the first iframe with standard height. Let me know for more requirements. Hope it helps!

about 4 years ago · Juan Pablo Isaza Relatório

0

You can use

window.getComputedStyle(element);

And it will give you an object with all css properties of that element.

If you want to get the height:

window.getComputedStyle(element).height;

And that will return ’150px’, or whatever else the height will be

Note: typing ‘window’ is not required, getComputedStyle() will also work

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