tags:

views:

3210

answers:

4

I have an iframe where the src is an htm file and this iframe is put inside usercontrol :

<iframe frameborder="0" src="CName.htm" align="left" width="730" height="1100" ></iframe>

i need the iframe to resized according to the content so that it's height is set according to the hieght of the html file and i don't need to use scrolling attribute do u have any ideas?

A: 

Resizing an IFrame gets ugly really quick. In fact, I don't think there's a good, cross-browser way to do what you want the way you want to.

Are you sure you need to do this? Perhaps you could consider a different approach?

Randolpho
A: 

You can figure out the height and width of the content inside the frame, then call a function that's on the frame's owner to set the iframe element's height and width.

Tom Ritter
+1  A: 

There is a way! Its in jquery and its too simple. Kinda hacky..

$('iframe').contents().find('body').css({"min-height": "100", "overflow" : "hidden"});
setInterval( "$('iframe').height($('iframe').contents().find('body').height() + 20)", 1 );

There you go!

Cheers! :)

Shripad K