I have a nested iFrame in a page. This iFrame calls another website, where I have content acting as a 'remote' for the site the iFrame is nested in.
--------------------------
-
| iframe | site |
| menu | content |
|----------| |
|content | |
| | |
--------------------------
--
I need to have the iFrame dynamicly resize to fit it's content, but there's a nasty part to this:
the iFrame has an AJAX Collapsible Panel in it containing a menu for the main site. Since it's a collapsible panel, it doesn't run on postbacks, so when the user expands a section of the menu, there's no actual event to indicate the iframe should increase in size.
I currently have a piece of code from MS for resizing, but the thing runs freaky. When I click the collapsible element in my menu, the frame stays as is while the panel opens. when I click again to collapse the panel, then the iFrame resizes to what that panel's size WAS.
FYI, here's the code:
parent page:
<iframe id="testMenu" name="testMenu"
frameborder="0" scrolling="no" height="100%" width="175"
src="
http://domain1:9999/Menu/" target="_top"></iframe>
the child page:
<script language="javascript" type="text/javascript">
function resizeToContent() {
var x = 0;
var y = this.document.body.scrollH
eight;
while (x < y) {
x+=1;
}
parent.document.getElement
ById('test
Menu').sty
le.height = x;
}
</script>
</head>
<body>
<%--What's Happening--%>
<cc1:CollapsiblePanelExten
der ID="CollapsiblePanelExtend
er1" runat="server"
SuppressPostBack="false" Collapsed="True" CollapseControlID="imgMenu
WHButton" CollapsedSize="0"
ExpandControlID="imgMenuWH
Button" TargetControlID="pnlMenuCo
ntainerWH"
TextLabelID="Label4" />
<asp:Image ID="imgMenuWHButton" runat="server" ImageURL="~/images/leftnav
_wh.jpg" CssClass="clsCursorPointer
" AlternateText="What's Happening" OnClick="resizeToContent()
" />
<asp:Panel ID="pnlMenuContainerWH" runat="server" CssClass="cls0pxHigh clsOneHundredPercentWide" style="height: 0px; overflow: hidden;">
<em>with</em> <asp:HyperLink ID="HyperLink1" runat="server" CssClass="lnkBlueBold clsNinetyPercentFont" NavigateUrl="
http://domain:3030/C7/Accounting News/" Text="Accounting" target="_top"/><br />
</asp:Panel>
Start Free Trial