A域引入B域的東西: html
<div style="max-width:1300px;" id="dashboard2Vm"> <iframe id="dashboardIframeId" scrolling="no" frameborder="0" width="101%" height="100%" name="dashboardIframName" src="$!{v1}/dashboard/view.action?q.head=n" ></iframe> </div>
B域中在加載頁面後初始化頁面的寬高,實現無縫融合 spa
//初始化父級頁面的高度和寬度 function initParentHeight(){ //獲取父級頁面的iframe對象 var pTar = parent.document.getElementById("dashboardIframeId"); //對ifram進行寬高設置 if (pTar && !window.opera){ pTar.style.display="block"; if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight){ pTar.height = pTar.contentDocument.body.offsetHeight + 50; //pTar.width = pTar.contentDocument.body.offsetWidth; }else if(pTar.Document && pTar.document.body.scrollHeight){ pTar.height = pTar.document.body.scrollHeight + 50; //pTar.width = pTar.document.body.scrollWidth; } } }