George L. Sexton wrote:
On Wed, 14 Mar 2007 13:30:19 -0700, la***********@zipmail.com wrote:
Hi,
Does anyone know a cross-browser way of making an iframe just as big
as the HTML content of its source, but no bigger, either width or
height wise. Using 100% attributes for iframe width and height seem
to make the iframe as big as its parent container. I would also
prefer a solution where there is no scrolling.
Thanks for any help, - Dave
There are some scripts on http://www.DynamicDrive.com that will do this as
long as both pages are in the same domain/host.
If both pages are from same domain then all you need to do is check
scrollHeight/scrollWidth -
IFrame.width=IFrame.document.body.scrollWidth
IFrame.height=IFrame.document.body.scrollHeight
E.G.-UNTESTED-
<html>
<head><title>Sometr</title>
<script type="text/javascript">
function OpenFrame(){
var Iframe=document.frames[0]
Iframe.src="somePage.html"
Iframe.onload=
function(){
Iframe.width=Iframe.document.body.scrollWidth
Iframe.height=Iframe.document.body.scrollHeight
}
}
</script>
<body style="text-align:center">
<button onclick="OpenFrame()">Text</button><br>
<IFRAME src="about
:blank" width="50%" height="30%">your browser
doesn;t support frames(bad browser :-< )</iframe>
</body>
</html>