html 架構之Iframe用法

來源:互聯網
上載者:User
一般我們經常碰到這樣的情境,在頁面需要包含別的頁面,當然可以用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');
   }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.