本文实例讲述了JS动态修改iframe高度和宽度的方法。分享给大家供大家参考。具体如下:
如果希望通过按钮动态修改iframe的高度和宽度,可以参考下面的JS代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <!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>
|
登录后复制
希望本文所述对大家的javascript程序设计有所帮助。