html 框架之Iframe用法

一般我们经常碰到这样的场景,在页面需要包含别的页面,当然可以用include来包含进来,可是不太灵活,如果根据我们的需要加载页面,那不是更好吗,IFrame是个不错的选择:
首先你在页面需要包含的地方加上
<iframe  name="IframeWidow"  id="IframeWidow"  frameborder="0"  src=""  style="border-style:solid;border-width:thin;display:none;position:absolute;"></iframe>

然后在js里面写个生成这个页面的方法

function IframeWidow_Open(sSrc,iWidth,iHeight,iTop,iLeft,sScrolling){
        var oIframe=document.all("IframeWidow");
        oIframe.onreadystatechange=onchangestatus;
        oIframe.src=sSrc;
         oIframe.style.width=iWidth;
         oIframe.style.height=iHeight;
         oIframe.style.zIndex=1;
         var iframeTop;
         var iframeLeft;
         if ((iTop=="") || (iTop==null))
         {
             iframeTop=((document.body.clientHeight/2) - (parseInt(oIframe.style.height)/20))-0 ;
             iframeTop=(iframeTop>0)?(iframeTop):(0);
         }else{
             iframeTop=iTop;
         }
         if ((iLeft=="") || (iLeft==null))
         {
             iframeLeft=((document.body.clientWidth/2) - (parseInt(oIframe.style.width)/2))-0;
             iframeLeft=(iframeLeft>0)?(iframeTop):(0);
         }else{

             iframeLeft=iLeft;
         }

        oIframe.style.top=iframeTop;
        oIframe.style.left=iframeLeft;

         switch (sScrolling)
         {
               case "yes" :
                 oIframe.style.scrolling="yes";
                 break;
               case "no" :
                   oIframe.style.scrolling="no";
                   break;
            default :
                oIframe.style.scrolling="auto";
                break;
        }
}

然后在没个时间里面设置好iframe的src调用即可
src可以是一个页面的url,也可以是
function showQuantityList(companyCode,partsCode,stockType,warehouseCode,warehouseLocationCode,warehouseType,ableUse_a_Qty,brand,articleNo,articleExtNo){
      
        var urlstr='<html:rewrite page="/***Action.do?method=**&companyCode="/>'+companyCode+'&partsCode='+partsCode+'&warehouseCode='+warehouseCode+'&warehouseLocationCode='+warehouseLocationCode+'&stockType='+stockType+'&ableUse_a_Qty='+ableUse_a_Qty+'&brand='+brand+'&articleNo='+articleNo+'&articleExtNo='+articleExtNo+'&warehouseType='+warehouseType;
        IframeWidow_Open(urlstr, 600, 450, 300, 200, 'auto');
   }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值