...

View Full Version : Iframe height mach content height



Alex Piotto
10-09-2002, 12:37 PM
Hallo, people!
It is possible to set the height of an iframe depending on the height of the content?
I mean, if the page included contain a few text the iframe has to be small, but if the text is a lot the iframe height should grow to show all the content without scrollbar.

Any suggestion?

thanks

Alex :)

Quiet Storm
10-11-2002, 06:07 AM
I've seen it done somewhere... I think it was just with FRAMEs, not iFRAMEs, though.

I'll see if I can find it again.

:)

adios
10-11-2002, 06:55 AM
<html>
<head>
<title>untitled</title>
<script type="text/javascript" language="javascript">

var oldHTML = '<html><head><title>untitled</title></head><body><h2>original</h2></body></html>';
var newHTML = '<html><head><title>untitled</title></head><body>';
newHTML += 'blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah ';
newHTML += 'blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah ';
newHTML += 'blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah ';
newHTML += 'blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah ';
newHTML += 'blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah ';
newHTML += 'blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah ';
newHTML += 'blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah ';
newHTML += 'blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah ';
newHTML += 'blah blah blah blah blah blah</body></html>';

function sizeit() {
var dWid = frames['IF'].document.body.scrollWidth;
var dHgt = frames['IF'].document.body.scrollHeight;
frames['IF'].resizeTo(dWid,dHgt);
}

</script>
</head>
<body>
<iframe id="IF" onload="sizeit()" scrolling="no" src="javascript&#58;parent.oldHTML"></iframe>
<br><br>
<a href="javascript&#58;document.getElementById('IF').src='javascript&#58;parent.newHTML';void(0)">
NEW</a>
</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum