Auto adjust iFrame to the webpage it's on?

Hello, I’d like to make an iframe that will automatically get the height of the webpage it is on (not the source url) - I’m not talking the browser viewport but the entire document - so basically the height in pixels minus a certain value to prevent the iframe from sliding out - example:


<iframe src="http://google.com/" height="CURRENT DOCUMENT'S HEIGHT MINUS 50" width="FIXED"></iframe>

Maybe it is better to achieve this function in php - or any other way? And perhaps there is some better way than an iframe - like a container of some sort that can automatically expand to the webpage’s length…

Thanks in advance!

This isn’t possible using only JavaScript due to the Same Origin Policy… unless of course you are trying to automatically size an iframe to be the height and width attributes of a page that is on YOUR domain. Is that the case?

If the page is on a different domain, e.g. Google.com, then you can’t get any elements or attributes of the page using Javascript through an iframe. You can always use PHP cURL or something to actually HTTP GET the HTML on the page, and then alter the iFrame using what you HTTP GOT.

Thanks, already solved it.