Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Calculating Height of a Div
Old 11-06-2007, 02:18 AM Calculating Height of a Div
Average Talker

Posts: 18
Trades: 0
Best to show in code and then explain.

Code:
<div style="display:none;width:250px;margin-left:-250px;position:absolute;background-color:#f1f1f1;" id="container">
											
	<div id="myframe" style="filter: alpha(opacity=0); z-index:10; height: 100%; overflow: hidden; width: 250px;position: absolute;">
		<iframe id="'eliframe'" style="z-index:10; width: 250px;" frameborder="0"></iframe>
	</div>


	<div id="overlay12" style="position: absolute;z-index:18;width:250px;border:1px solid #005cb1;position:absolute;background-color:#f1f1f1;">
		-[CONTENT]-
	</div>
		
		
	<script type="text/javascript">
window.onload = getH;
 
function getH(){		
var divh = document.getElementById("container").offsetHeight;
		alert(divh);
}
	</script>
			        
</div>
So I need the height of the iframe to reflect the height of the div.
The Div height is based on the amount of content that is inserted into it on page load (so I can't set an absolute height).

The iframe is to allow the help popup to tile over dropdown menus in IE.

The script above doesn't return the height of the #container element it returns a "0".

I need it to figure out the height on page load, and I can't seem to do it for the life of me.

Please help!
__________________

Please login or register to view this content. Registration is FREE
- PR3, High traffic, selling space on homepage. - $4 per month
ogbecker is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-06-2007, 04:07 AM Re: Calculating Height of a Div
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
the script runs before the div is closed so it doesn't exist in the DOM
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-06-2007, 04:30 AM Re: Calculating Height of a Div
Average Talker

Posts: 18
Trades: 0
I was hoping that the window.onload would take care of that.

This is a component that will go on many pages. so I would prefer that it was self contained.

Suggestions? Thank you for the help!
__________________

Please login or register to view this content. Registration is FREE
- PR3, High traffic, selling space on homepage. - $4 per month
ogbecker is offline
Reply With Quote
View Public Profile
 
Old 11-06-2007, 04:53 AM Re: Calculating Height of a Div
Average Talker

Posts: 18
Trades: 0
oh wait, you're saying to just put it after the </div> and it should work?

(I'll try that first thing tomorrow.)
__________________

Please login or register to view this content. Registration is FREE
- PR3, High traffic, selling space on homepage. - $4 per month
ogbecker is offline
Reply With Quote
View Public Profile
 
Old 11-06-2007, 06:46 AM Re: Calculating Height of a Div
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
or use an onload event on the div itself to call the method.

put the function code into an external file or in the document head first of course
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-03-2007, 10:19 AM Re: Calculating Height of a Div
Junior Talker

Posts: 1
Trades: 0
Try scrollHeight instead of scrollHeight
govi is offline
Reply With Quote
View Public Profile
 
Old 12-03-2007, 11:40 AM Re: Calculating Height of a Div
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by govi View Post
Try scrollHeight instead of scrollHeight
Ermmm?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Calculating Height of a Div
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.24383 seconds with 12 queries