2012-03-18 182 views
0

我包括母版页中的iframe,我想根据里面的内容以调整iframe高度。调整大小自动iframe高度

当过iframe中的内容增加iframe的高度应该增加。

<div id="div_NotificationOuter" style="position: fixed; bottom: 0px; right: 15px; 
      padding: 5px; background-color: White; background-image: url('../images/content_fixed_downup.png'); 
      background-repeat: no-repeat; min-height: 130px; text-align: left; display: block; 
      border: 1px solid gray; width: 280px; overflow: hidden;"> 

    <asp:ImageButton ID="img1b" runat="server" ImageUrl="../images/close.png" 
       Style="margin-right: 2px;float:right;" OnClientClick="Hide_NotifyPopUp()" /> 

说注意

您的浏览器并不支援iframe。

和iframe页面

<div id="iframe_content"> 
     <div style="overflow: auto;font-weight:bold " > 
      <label id="lblNotifyMessage" runat="server" style="margin-left:15px;"> 

      </label> 
     </div> 
     <div style="font-size: 14px;margin-left:15px;"> 
      <asp:Label ID="lblCount_Followups" runat="server" Text="" 
       Style="margin: 2px"></asp:Label><br /> 
      <asp:Label ID="lblCount_Workflow" runat="server" Text="" 
       Style="margin: 2px"></asp:Label><br /> 
      <asp:Label ID="lblCount_Inbox" runat="server" Text="" 
       Style="margin: 2px"></asp:Label><br /> 
      <asp:Timer ID="Timer1" runat="server" Interval="111115000"> 
      </asp:Timer> 

      <asp:Label ID="Label1" runat="server" Text="Notification Message" 
       Style="margin: 2px"></asp:Label><br /> 
      <asp:Label ID="Label2" runat="server" Text="Notification Message" 
       Style="margin: 2px"></asp:Label><br /> 
      <asp:Label ID="Label3" runat="server" Text="Notification Message" 
       Style="margin: 2px"></asp:Label><br /> 


      <asp:Label ID="Label4" runat="server" Text="Notification Message" 
       Style="margin: 2px"></asp:Label><br /> 
      <asp:Label ID="Label5" runat="server" Text="Notification Message" 
       Style="margin: 2px"></asp:Label><br /> 
      <asp:Label ID="Label6" runat="server" Text="Notification Message" 
       Style="margin: 2px"></asp:Label><br /> 


      <asp:Label ID="Label7" runat="server" Text="Notification Message" 
       Style="margin: 2px"></asp:Label><br /> 
      <asp:Label ID="Label8" runat="server" Text="Notification Message" 
       Style="margin: 2px"></asp:Label><br /> 
      <asp:Label ID="Label9" runat="server" Text="Notification Message" 
       Style="margin: 2px"></asp:Label><br /> 

     </div> 
     </div> 

回答

0

假设你拥有jQuery和你知道什么时候该内容高度的变化,你可以用这个调整它的大小:

$('#iframe').height($('#iframe_content').height());

+0

whery我shuld使用此功能 – adilahmed 2012-03-18 13:20:49

0

你必须在iframe的父页面上调用一个函数来执行此操作。

在父页面,创建这样

function resizeIframe(var) { 
    $("iframeid").height(var); 
} 

类似的功能现在,从iframe中调用下面的代码片段

$(window).load(function() { 
//^Once everything load. You can change this any event suitable 
    parent.resizeIframe($(window).outerHeight()); 
});