Sunday, January 25, 2009

[jQuery] Re: Can JQuery solve the iframe height=100% problem?

Hi dbzz,

I tried the code you provided, but went from this ...

http://screencast.com/t/W8lOtgKO

to the iframe disappearing entirely ...

http://screencast.com/t/jCTjOLhpeX

I put your code in a $(document).ready() block (below). Are there any
other modifications I should make to get it to display at 100%?

$(document).ready(function() {
$('#fileTreeIframe').load( function() {
var $ifbody = $(this).contents().find
( 'body' );
$ifbody.css( 'height','auto' );
$(this).height( $ifbody.height() );
});
});

Thanks, - Dave


On Jan 25, 10:26 am, dbzz <j...@briskey.net> wrote:
> let me change that - i actually went and looked at the place i had
> this working and it goes like this -
>
>         $('#fileTreeIframe').load( function() {
>                 var $ifbody = $(this).contents().find( 'body' );
>                 $ifbody.css( 'height','auto' );
>                 $(this).height( $ifbody.height() );
>         });
>
> ...need more coffee.
>
> On Jan 25, 7:36 am, dbzz <j...@briskey.net> wrote:
>
>
>
> > see if this works. chances are that the iframe content hasn't loaded
> > yet when onready runs, so bind the height change to the iframe load
> > callback.
>
> >         var $ifbody = $('#fileTreeIframe').contents().find( 'body' );
> >         $ifbody.bind( 'load', function() {
> >                 $('#fileTreeIframe').height( $ifbody.height() );
> >         });- Hide quoted text -
>
> - Show quoted text -

No comments: