您现在的位置是:首页 > 电脑技术查询 > web开发

怎么让<iframe></iframe>(内嵌框架)的大小随着窗口显示的大小而改变高度和宽度

编辑:chaxungu时间:2022-10-02 23:21:41分类:web开发

如何让<iframe></iframe>(内嵌框架)的大小随着窗口显示的大小而改变高度和宽度?
如何让 <iframe> </iframe> (内嵌框架)的大小随着窗口显示的大小而改变高度和宽度?

------解决方案--------------------
这个例子里iframe一直和窗口一样大.
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=GBK ">
<title> </title>
<script type= "text/javascript ">
function resizeFrame()
{
document.all( "f1 ").width = document.body.clientWidth;
document.all( "f1 ").height = document.body.clientHeight;
}
window.onresize = resizeFrame;
window.onload = resizeFrame;
</script>
</head>
<body style= "margin:0 0 0 0; ">
<iframe src= " " id= "f1 " style= "margin:0 0 0 0; "> </iframe>
</body>
</html>
------解决方案--------------------
iframe.width = document.body.offsetWidth;
iframe.height = document.body.offsetHeight;