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

118
Views
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 answers
Answer question

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 Report

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 Report
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!