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 >

这里参考:

http://www.yourhand.cn/special/jsjq/i/iframe/iframe3.htm

非常感谢

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值