Reply
Javascript to set div height based on _unused_ space
Old 09-26-2008, 05:25 PM Javascript to set div height based on _unused_ space
Experienced Talker

Posts: 38
Name: Kerrick
I am relatively new at Javascript, so please bear with me. I'm trying to find out the height of space from the bottom of the outputted HTML from a PHP program, to the bottom of the viewport, and have Javascript set my next div height as that amount. Is this possible, assuming that the outputted HTML can vary from page load to page load, and even on one load due to a collapsible header?
Kerrick is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 09-26-2008, 06:18 PM Re: Javascript to set div height based on _unused_ space
chrishirst's Avatar
Super Moderator

Posts: 16,446
Location: Blackpool. UK
http://www.webmaster-talk.com/javasc...avascript.html
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-26-2008, 06:25 PM Re: Javascript to set div height based on _unused_ space
Experienced Talker

Posts: 38
Name: Kerrick
Believe it or not, I did look at that thread before posting this. However, I need something like this:

pseudo-code:
Code:
<html><head></head><body>
<div class="output">
lorem ipsum
</div>
<div id="frame">
my content here
</div>
</body></html>
Where the outputted content can be anything, and I'd need something like:
Code:
document.getElementById(DivID).style.height = document.getElementById(DivID).clientHeight - document.getElementByClass(output).style.height
Kerrick is offline
Reply With Quote
View Public Profile
 
Old 09-26-2008, 06:46 PM Re: Getting Div Height using JavaScript
Experienced Talker

Posts: 38
Name: Kerrick
Nevermind, I found it. Here's the code, in case anybody wants to know.
Code:
      <iframe id="frame" style="width:100%;border:0;padding:0;margin:0;background:white;" src="http://www.webmaster-talk.com"></iframe>
	  <script type="text/javascript">
function resizeIframe() {
    var height = document.documentElement.clientHeight;
    height -= document.getElementById("frame").offsetTop;
    document.getElementById("frame").style.height = height +"px";
    
};
document.getElementById("frame").onload = resizeIframe;
window.onresize = resizeIframe;
</script>
Kerrick is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Javascript to set div height based on _unused_ space
 

Thread Tools

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

vB 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.12570 seconds with 12 queries