Javascript DOM HTML IFrame width Property set height and width

Introduction

Change the height and width of an iframe:

Click the button to change the height and width of the iframe to 400px.

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>

<script>
function myFunction() {/*  w w  w.j a  va 2s  .  c o  m*/
  document.getElementById("myFrame").height = "400";
  document.getElementById("myFrame").width = "400";
}
</script>

</body>
</html>



PreviousNext

Related