1.11M Members

How to make ImageButton load its content before I obtain iframe height

 
0
 

I have a control contained in an iframe on a page of my ASP.NET web application. Control changes its vertical size correspondingly to what user selects on it (some elements get in, others get out). So, I have to set the iframe size precisely to get the whole control shown and not to make gap between the iframe and the elements below it.

On self.document.body.onload on the control page, hence, I call this function:

    function adjustIframeHeight() {
    var iframe = window.parent.document.getElementById(window.frameElement.id);
    var iframeHeight = jQuery(iframe.contentWindow.document).height();
    iframe.style.height = iframeHeight + "px";
}

The problem is sometimes I get images at the bottom of the frame cutoff since the frame height is obtained before the images are loaded. I can see that, since after page refreshing I get the frame height set properly.

Is there a way to tell images to load before? I am using ASP.NET ImageButton-s and I am setting their ImageUrl property

LastMitch
Deleted Member
 
0
 

The problem is sometimes I get images at the bottom of the frame cutoff since the frame height is obtained before the images are loaded. I can see that, since after page refreshing I get the frame height set properly.

Since the image gets cut off then try this:

http://www.dyn-web.com/tutorials/iframes/fluid/

I post the javascript code from the link to here (so you can see it or you can read it from the link):

function setIframeHeight(id, h) {
    var ifrm = document.getElementById(id);
    if (ifrm) {
        var winHt = dw_Viewport.getWinHeight();
        ifrm.style.height = Math.round( h * winHt ) + "px";
        ifrm.style.marginTop = Math.round( ( winHt - parseInt(ifrm.style.height) )/2 ) + "px";
    }
}

window.onload = function() { setIframeHeight('ifrm', .8); }
window.onresize = function() { setIframeHeight('ifrm', .8); }

I mean you got the content loading already. So I assume you got your Asp.Net button working too then I think it's just the iFrame Javascript issue.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: