Is there a way to set the height of the iframe to be the same as the height of its source?
I am trying to
a) Avoid scrollbars and
b) Avoid using fixed height in px
Thank you. :)
views:
198answers:
3Sweet :) Although I can not use this (no control of the source page), it is nice to know! Thanks!
john
2010-03-28 12:40:15
+1
A:
Since the source page is on a different domain — no.
The only way to adjust its size based on the content is to measure the rendered size of the content using JavaScript, and the Same Origin Policy will prevent this.
David Dorward
2010-03-28 12:14:33
A:
if i understand correctly you have control over the iframe-content? in that case i wrote a javascript thingie (squeezeFrame.js) a couple of weeks ago, that can do just what you need.
essentially it uses;
- clientWidth (and optionally -Height) to get the size of the "viewport"
- scrollWidth (again optionally -Height) to get the size of the entire (iframed) page
- zoom (and -moz-transform: scale for firefox) to zoom in/out
you can see a couple of demo's of squeezeFrame.js in action here
futtta
2010-04-04 04:24:11
No, no control over the content inside the iframe, unfortunately. Thank you for your contribution, it could be useful in other situations than mine, and it is good to know!
john
2010-04-05 16:09:49