The height
attribute from iframe element
specifies the height of an iframe.
The height
property sets or gets the value of the height attribute in an iframe element.
height |
Yes | Yes | Yes | Yes | Yes |
Return the height property.
var v = iframeObject.height
Set the height property.
iframeObject.height=pixels
Value | Description |
---|---|
pixels | The height in pixels |
A String type value representing the height of the iframe in pixels.
The following code shows how to get the height of an iframe.
<!DOCTYPE html>
<html>
<body>
<iframe id="myFrame" src="http://example.com" height="200" width="250"></iframe>
<p id="demo"></p>
<!-- ww w. j av a2 s . c o m-->
<button onclick="myFunction()">test</button>
<script>
function myFunction() {
var x = document.getElementById("myFrame").height;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to change the height of an iframe.
<!DOCTYPE html>
<html>
<body>
<iframe id="myFrame" src="http://example.com" height="200" width="250"></iframe>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!-- w w w . j a va 2s .c om-->
document.getElementById("myFrame").height = "400";
}
</script>
</body>
</html>
The code above is rendered as follows: