JS's method of dynamically modifying the height and width of iframe

  • 2020-05-24 05:14:30
  • OfStack

This example shows how JS can dynamically modify the height and width of iframe. Share with you for your reference. The details are as follows:

If you want to change the height and width of iframe dynamically via the button, you can refer to the JS code below


<!DOCTYPE html>
<html>
<head>
<script>
function changeSize()
{
document.getElementById("myframe").height="300";
document.getElementById("myframe").width="300";
}
</script>
</head>
<body>
<iframe id="myframe" src="/default.asp" 
height="200" width="200">
<p>Your browser does not support iframes.</p>
</iframe>
<br><br>
<input type="button" onclick="changeSize()" 
value="Change size">
</body>
</html>

I hope this article has been helpful to your javascript programming.


Related articles: