两个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
>
这里参考:
http://www.yourhand.cn/special/jsjq/i/iframe/iframe3.htm
非常感谢
本文介绍了一种使用JavaScript动态调整HTML框架集(frameset)中框架(frame)大小的方法。通过按钮点击事件,可以实现框架的高度调整,从而隐藏或显示特定框架。此外,还提供了通过iframe元素调整宽度和高度的示例。

1144

被折叠的 条评论
为什么被折叠?



