|
在javascript中如何动态改变框架frame,iframe的大小呢?下面是示例程序:两个html
1.index.html
<html> <head> <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>动态改变框架大小 by 闫磊 Email:Landgis@126.com,yanleigis@21cn.com 2007.11.22</title> </head>
<FRAMESET name="full" rows="50%,50%"> <FRAME SRC="main.htm"> <FRAME SRC="main.htm"> </FRAMESET> </html>
2.main.h
<HTML> <TITLE>Form Object example</TITLE> <HEAD> <SCRIPT LANGUAGE="JavaScript"> function fttop() { if (document.getElementById("yltop").value=="隐藏上部"){ document.getElementById("yltop").value="隐藏下部"; parent.full.rows="0,*"; } else { document.getElementById("yltop").value="隐藏上部"; parent.full.rows="*,0"; } } function ftall() { parent.full.rows="50%,50%"; } </SCRIPT> </HEAD> <BODY> <FORM NAME="evalform" METHOD="get"> <input type="button" name="yltop" id="yltop" onclick="fttop();" value="隐藏上部"> <input type="button" name="ylall" id="ylall" onclick="ftall();" value="显示全部"> </FORM> </BODY> </HTML> 运行index.html
修改iframe方法如下
<iframe id="frame1" src="1.htm" width="100px" height="100px"></iframe> <br> <input type="button" value="加宽" onclick="addWidth()"> <input type="button" value="加高" onclick="addHeight()"> <script language="javascript"> function addWidth() { var o=document.getElementById("frame1"); o.width=eval(o.width)+10; } function addHeight() { var o=document.getElementById("frame1"); o.height=eval(o.height)+10; } </script>
|