I need a script that will automatically re-size the height of an iframe depending o the page in contains. I've tried many different ones that work when increasing the size, but not decreasing it too. Can anyone help?
11-03-2009, 04:06 AM
This is a tricky proposition. In our last encounter I believe I mentioned that since iframe is being deprecated, one should consider other means of organizing one's site. The current wave in this regard is AJAX. Tried and true is the use of server side includes, PHP being the most widely used server side language for that, asp second, there are many others. But to use a server side language, your host must have it enabled for your use, and it often (depending upon how you want to implement it, what you want to do) requires more page reloads than most designers want to have for a given site.
There are some other methods on the horizon, most notably the object tag, which still doesn't have wide enough browser support in my opinion.
However, due to the effort on most browsers part to be backward compatible, iframe may still be used. The only problem (aside from what I mentioned before about all of the pages having to be on the same domain, which is also an issue with AJAX BTW) is that the pages loaded into the iframe need to follow certain conventions as far as layout goes in order to be able to be easily read as to document.body.offsetHeight or whatever equivalent is used to fetch (from the contained document) to determine the height of the containing iframe. Also, the page where the iframe element is (often referred to as the 'top' page), must also fulfill certain layout requirements for this to work.
In other words, avoid tables and positioned elements on both the contained page(s) and the 'top' page.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.