Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make iFrame fit contents?

Status
Not open for further replies.

jsteph

Technical User
Oct 24, 2002
2,562
US
Hi all,
I have a simple html table that I display in an iframe, which is generated on an ASP page. Based on the data, the table may be wide or narrow, short or tall. Without doing any complex calculations on the table's cells, is there a simple way to just tell the iframe to stretch or shrink to fit the html table?

If this isn't simply done, can anyone direct me to the simplest "close-enough" way to calc the width/height of the resultant html table? Currently the table's cells shrink and grow based on the text within. If I have to force them to a reasonable standard size, I will do that.

Thanks,
--Jim
 
technically no there is no cut and dry methodoligy, although there are a few options and not the most pleasant to do.

embed some javascript for the iframe onload to examine the table and resize the iframe

if you are generating the table you can count the length of the strings of each field going across and find the largest ones of each and use those as max's for each <TD> and guestimate the overall width of the table, gutters, then appropriately size the iframe.

sorry to not be of more assistance, but for the most part you're asing to do a post process , in a pre-process language.

when you HTML in an iframe, you are making basically an after the fact load of data into a page, and that in turn turns most any sizing ordeal to the client side.

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
" I always think outside the 'box', because I'm never in the 'loop' " - DreX 2005
 
I'd look at the jQuery framework to do this.

Is this a single load iFrame, or will users be navigating through/reloading the iFrame content, and do you need it to resize with each load?

Client-side Ajax would be a better solution if you had control of the loaded content and would fix your sizing issue. It just becomes page content and you can control with css.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top