I have a normal html document with an iframe pointed to a .php document (with links to other php documents). I would like the iframe height an/or width to change when page in the iframe changes. For example the initial page would generate an iframe height/width of 800/600. When you click a link in the iframe, the height/width would change to 600/400. Then yet another link would change the iframe, hight/width to 400/900.

I was thinking that i could somehow have variables for height and width set on each of the php documents that might show up in the iframe, and that each time a new page was loaded in the frame the new height/width variables would be sent to the parent frame, and the parent frame would refresh generating an iframe with the new dimensions.

I hope it is clear what I'm trying to do, I can try to clarify if necessary. The main point is I want an iframe to change dimensions base on the content. I don't mind if the parent frame has to refresh, but it must be automatic.

I don't really know much about php code, so I don't know if the idea I explicated above is the best method, or even if it is possible. If there is a better way please tell me how. If it is the best way, how would I code that?


You need to ask this question in a javascript group, they'll know.

I did...
They told me to ask in the PHP forums. :(

PHP has no knowledge what's happening on the client side. With javascript this may be possible,

try Google: javascript resize iframe

a pritaeas says it can be done by using javascript only, through javascript you make an object by id of the iframe, so that you can get the dimensions of the iframe.
then you can send a value for test to which size you want resize you frame, so by comparing the value you can resize for your size.

if you want for better optimization of the image disply you can use AJAX.

try this, otherwise if you send your code,
i can help you with the code.