PDA

View Full Version : [TUT] Onload="calcheight()"



VirtualG
03-09-2009, 08:37 AM
If you are getting angry with you're iframes because they do not expand to the correct size, this is a quick and easy way to get them to expand to the correct height.
Step one:
insert the following code into the head tags:

<script language="JavaScript">
<!--

function calcHeight()
{
//find the height of the internal page
var the_height=
document.getElementById('the_iframe').contentWindo w.
document.body.scrollHeight;

//change the height of the iframe
document.getElementById('the_iframe').height=
the_height;
}
//-->
</script>

(replace 'the_iframe with the iframe id.)
Step Two:
Put onload="calcheight()" into you're iframe tags (make sure there is no height specified) and you're done!
__________________________________________________ __________________________________________________ ____________
Easy or what? I hope you enjoyed it, it's used for more 'novice' coders. I just saw a post with someone asking how to do it.

BoyBetterKnow
03-09-2009, 12:13 PM
Tbh people shouldn't be using iframes imo. They are a waste of space.

Good information though.

Invent
03-09-2009, 01:30 PM
Tbh people shouldn't be using iframes imo. They are a waste of space.

Good information though.

IFrames can be useful when used correctly. Oh and I'm sure this code doesn't work in certain browsers.

BoyBetterKnow
03-09-2009, 04:39 PM
IFrames can be useful when used correctly. Oh and I'm sure this code doesn't work in certain browsers.

Okay man I hear that. Where would you use iframes and what for?

Invent
03-09-2009, 04:55 PM
Okay man I hear that. Where would you use iframes and what for?
WYSIWYG editors?

BoyBetterKnow
03-09-2009, 05:32 PM
WYSIWYG editors?

Okay fair enough. Content wise you wouldn't use them though right?

Invent
03-09-2009, 05:58 PM
Okay fair enough. Content wise you wouldn't use them though right?
No, I personally wouldn't use them to display internal content but I would use them for other things :)

BoyBetterKnow
03-09-2009, 06:04 PM
No, I personally wouldn't use them to display internal content but I would use them for other things :)

Fair enough. We just raped this thread lol.

iDenning
03-09-2009, 08:56 PM
Fair enough. We just raped this thread lol.
You rape alot of things..

ha joke :P

And I don't see whats wrong with iFrames? If you use them correctly, your ok?

VirtualG
03-09-2009, 09:18 PM
Exactly, theres nothing wrong with iframes if used correctly, eg HabboArchive.net

BoyBetterKnow
04-09-2009, 09:39 AM
I don't like HabboArchive.net tbh.

VirtualG
04-09-2009, 10:11 PM
I don't like HabboArchive.net tbh.
It's a matter of opinion, I guess

Want to hide these adverts? Register an account for free!