一般我們經常碰到這樣的情境,在頁面需要包含別的頁面,當然可以用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');
}