1

I have the iframe:

<!DOCTYPE html>
<html>

   <body>
   <div style="height:300px;width:100%;background:red" class="embed-responsive">
    <iframe src="test.html" width="auto" height="auto" class="embed-responsive-item" allowfullscreen webkitallowfullscreen mozallowfullscreen frameborder="0"></iframe>
    </div>
    </html>

I want to obtain in my test.html the effective height of iframe (not auto but 300px)

I tried to do this:

parent.document.getElementsByTagName("iframe")[0].getAttribute("height");

But the results is auto and not 300

Somebody can help me?

user880386
  • 2,737
  • 7
  • 33
  • 41
  • `getAttribute` unsurprisingly, gets the attribute value (note that `auto` is **invalid** HTML), not the computed height of the element. – Quentin Mar 05 '19 at 14:12
  • 1
    var iframe = parent.document.getElementsByTagName("iframe")[0]; iframe.offsetHeight; – Zohid Mar 05 '19 at 14:13
  • Try with parent.document.getElementsByTagName("iframe")[0].height – jare25 Mar 05 '19 at 14:15

0 Answers0