2012-06-05 55 views
0

我有一些標題爲Custom_News,Custom_Articles和CUstom_Cases的HTML主頁自定義組件。如何讓我的客戶門戶網站自動調整其組件大小?

下面是他們的HTML:

<iframe src="/apex/NewsPage?id=a1TW0000000EJAL" frameborder="0" width="100%"></iframe>&nbsp;

<iframe src="/apex/Custom_Home" frameborder="0" width="100%"></iframe>&nbsp;

<iframe src="/apex/CasesPage" width="100%" frameborder="0"></iframe>&nbsp;

這是我的客戶門戶網站的主頁佈局的樣子:

enter image description here

,這就是自定義組件的樣子,當我登錄到客戶門戶:

enter image description here

如何擺脫滾動條的?我希望客戶門戶自動調整組件的大小,以便任何組件都不會有滾動條。我該怎麼做呢?

回答

0

這是我落得這樣做:

<script language="JavaScript"> 
    function resizeIframe(newHeight, id){  
     document.getElementById(id).style.height = parseInt(newHeight,10) + 'px'; 
} 
</script> 
<iframe id="iframe2" src="/apex/NewsPage?id=a1TW0000000EJAL" frameborder="0" ="" onload="parent.resizeIframe(1.5*document.body.clientHeight,'iframe2');" height="100%" width="100%"></iframe> 
2

您可以嘗試使用JavaScript動態修改iframe的高度。這answer解釋如何做到這一點。

下面是使用JavaScript provided一個例子:

<script language="JavaScript"> 
<!-- 
function autoResize(id){ 
    var newheight; 
    var newwidth; 

    if(document.getElementById(id)){ 
     newheight = document.getElementById(id).contentWindow.document.body.scrollHeight; 
     newwidth = document.getElementById(id).contentWindow.document.body.scrollWidth; 
    } 

    document.getElementById(id).height = (newheight) + "px"; 
    document.getElementById(id).width = (newwidth) + "px"; 
} 
//--> 
</script> 

<iframe src="/apex/NewsPage?id=a1TW0000000EJAL" frameborder="0" width="100%" onLoad="autoResize('iframe1');"></iframe>&nbsp;

<iframe src="/apex/Custom_Home" frameborder="0" width="100%" onLoad="autoResize('iframe1');"></iframe>&nbsp;

<iframe src="/apex/CasesPage" width="100%" frameborder="0" onLoad="autoResize('iframe1');"></iframe>&nbsp;

+0

我將JavaScript文件放入Salesforce的哪一部分? iframe部分如何知道在哪裏查找autoResize函數? –

+0

嘗試在您的一個iframe標記之前添加它。 –

+0

我在iframe之前添加了它,並更改了iframe代碼,它沒有做任何事情。滾動條仍然存在。 –

相關問題