Javascript DOM HTML IFrame height Property get

Introduction

Return the height of an iframe:

var x = document.getElementById("myFrame").height;

Click the button to display the height of the iframe.

View in separate window

<!DOCTYPE html>
<html>
<body>

<iframe id="myFrame" src="https://www.java2s.com" height="200" width="250"></iframe>
<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*from ww  w. j  a va 2 s.  c  om*/
  var x = document.getElementById("myFrame").height;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related