Click here to Skip to main content
13,552,926 members
Rate this:
 
Please Sign up or sign in to vote.
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 6-Jul-11 23:37pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

u can try this

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

i want to set of iframe height according to the source page height not static.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Hi,

Try this function in your js.

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
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web03 | 2.8.180515.1 | Last Updated 7 Jul 2011
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100