日期:2014-05-16  浏览次数:20323 次

如何让<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;