Click here to Skip to main content
15,940,271 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

i am using i frame i want to resize the iframe height according to content.but the thing is frame is loaded only once and when the page containing the iframe is opened as modal pop up, the modal pop containing the iframe does not have the height according to the content any idea ?
Posted

u can try this

<iframe id="i1" src="Home.aspx" runat="server"></iframe>
i1.Attributes.Add("Height","500");
 
Share this answer
 
Comments
kjsl2k9 7-Jul-11 6:33am    
hi,

i want to set of iframe height according to the source page height not static.
Hi,

Try this function in your js.

C#
function setIframeHeight(iframeName, IsCallFromIFrame) {

    if (IsCallFromIFrame) {
        iframeEl = parent.document.getElementById(iframeName);
    }
    else {
        iframeEl = document.getElementById ? document.getElementById(iframeName) : document.all ? document.all[iframeName] : null;
    }
    if (iframeEl) {
            iframeEl.style.height = $(document).height() + 10 + "px";
            return;
        }
}


Regards,

Anand
 
Share this answer
 
Comments
kjsl2k9 7-Jul-11 6:34am    
Am not using jquery so $(document).height() is no use any other idea
Anand Ranjan Pandey 7-Jul-11 7:08am    
is there any specific reason not to use jQuery ?

document.getElementById(iframeName).style.height = // some height


is also working f9 with me.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900