473,623 Members | 2,447 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

changing div height with javascript makes div with more than 100%

5 New Member
what up people, i'm writing an app which includes a page that has 2 divs side by side. the page is set up to fill the table containing the divs to 100% of the width of the pages. I want the height of these divs to also move with the resize of the page but also keep in prospective the other table space above and below the divs.

My solution to this was to manipulate the height with javascript using the method below. this works however, the width is thrown out of wack and goes beyond 100% of the page. Am i missing something in the script that is causing this? The problem only exists in internet exlporer, firefox it is fine.

Also below is the style i used:


function resizeTreeDivs( LTree, RTree){
var winHeight = document.docume ntElement.clien tHeight;
var appHeight = winHeight -189;
var parDivL = LTree.parentNod e;
var parDivR = RTree.parentNod e;

parDivL.style.h eight = appHeight+'px';
parDivR.style.h eight = appHeight+'px';
}


.divs {
overflow: auto;
height: 400px;
margin: 0px;
padding: 0px;
position: relative;
left: 0px;
top: 0px;
clear: right;
float: left;
width: 100%;
}

Thanks in advance!
Joe Estes
Jan 10 '07 #1
4 4254
b1randon
171 Recognized Expert New Member
what up people, i'm writing an app which includes a page that has 2 divs side by side. the page is set up to fill the table containing the divs to 100% of the width of the pages. I want the height of these divs to also move with the resize of the page but also keep in prospective the other table space above and below the divs.

My solution to this was to manipulate the height with javascript using the method below. this works however, the width is thrown out of wack and goes beyond 100% of the page. Am i missing something in the script that is causing this? The problem only exists in internet exlporer, firefox it is fine.

Also below is the style i used:


function resizeTreeDivs( LTree, RTree){
var winHeight = document.docume ntElement.clien tHeight;
var appHeight = winHeight -189;
var parDivL = LTree.parentNod e;
var parDivR = RTree.parentNod e;

parDivL.style.h eight = appHeight+'px';
parDivR.style.h eight = appHeight+'px';
}


.divs {
overflow: auto;
height: 400px;
margin: 0px;
padding: 0px;
position: relative;
left: 0px;
top: 0px;
clear: right;
float: left;
width: 100%;
}

Thanks in advance!
Joe Estes
Post your full page source so that I can debug, pls.
Jan 11 '07 #2
atma86
5 New Member
the source xhtml portion with the problem divs:
-------------------------------------------------------------------

<table width="100%" border="0" cellspacing="0" cellpadding="0" >
<tr valign="top">
<td width="32" background="ima ges/layout/bdlft.jpg"><img src="images/layout/bdlft.jpg" width="32" height="10" /></td>
<td width="50%">
<div id="roadmapTree Div" class="divs">
<t:tree2 id="roadmapTree " value="#{roadma pTreeBean.treeM odel}" var="_node" varNodeToggler= "t" showLines="fals e" org.apache.myfa ces.tree2.CLIEN T_SIDE_TOGGLE=" true" org.apache.myfa ces.tree2.SHOW_ ROOT_NODE="true " org.apache.myfa ces.tree2.SHOW_ NAV="true">
<ims:tnc entity="${_node }" fieldName="fld1 "/>
<ims:tnc entity="${_node }" fieldName="fld2 "/>
<ims:tnc entity="${_node }" fieldName="fld3 "/>
<ims:tnc entity="${_node }" fieldName="fld4 "/>
<ims:tnc entity="${_node }" fieldName="fld5 "/>
<ims:tnc entity="${_node }" fieldName="fld6 "/>
<ims:tnc entity="${_node }" fieldName="fld7 "/>
<ims:tnc entity="${_node }" fieldName="fld8 "/>
<ims:tnc entity="${_node }" fieldName="fld9 "/>
<ims:tnc entity="${_node }" fieldName="fld1 0"/>
<ims:tnc entity="${_node }" fieldName="fld1 1"/>
</t:tree2>
</div>
</td>
<td width="1" bgcolor="#867F8 7"><img src="images/layout/divider.jpg" width="1" height="1" /></td>
<td width="50%">
<div id="auditTreeDi v" class="divs">
<t:tree2 id="auditTree" value="#{auditT reeBean.treeMod el}" var="_node" varNodeToggler= "t" showLines="fals e" org.apache.myfa ces.tree2.CLIEN T_SIDE_TOGGLE=" true" org.apache.myfa ces.tree2.SHOW_ ROOT_NODE="true " org.apache.myfa ces.tree2.SHOW_ NAV="true">
<ims:tnc entity="${_node }" fieldName="fld1 "/>
<ims:tnc entity="${_node }" fieldName="fld2 "/>
<ims:tnc entity="${_node }" fieldName="fld3 "/>
<ims:tnc entity="${_node }" fieldName="fld4 "/>
<ims:tnc entity="${_node }" fieldName="fld5 "/>
<ims:tnc entity="${_node }" fieldName="fld6 "/>
<ims:tnc entity="${_node }" fieldName="fld7 "/>
<ims:tnc entity="${_node }" fieldName="fld8 "/>
<ims:tnc entity="${_node }" fieldName="fld9 "/>
<ims:tnc entity="${_node }" fieldName="fld1 0"/>
<ims:tnc entity="${_node }" fieldName="fld1 1"/>
</t:tree2>
</div>
</td>
<td width="32" background="ima ges/layout/bdrt.jpg"><img src="images/layout/bdrt.jpg" width="32" height="10" /></td>
</tr>
</table>

again the css is:
------------------------

.divs {
overflow: auto;
height: 400px;
margin: 0px;
padding: 0px;
position: relative;
left: 0px;
top: 0px;
clear: right;
float: left;
width: 100%;
}

and the javascript that manipulates the divs once the page is loaded:
--------------------------------------------------------------------------------------------------

function resizeTreeDivs( LTree, RTree){
//these two trees are spans
var winHeight = document.docume ntElement.clien tHeight;
var appHeight = winHeight -189;
var parDivL = LTree.parentNod e;
var parDivR = RTree.parentNod e;

parDivL.style.m argin = 0+'px';
parDivL.style.w idth = '100%';
parDivL.style.p osition = 'relative';
parDivL.style.p adding = 0+'px';
parDivL.style.l eft = 0+'px';
parDivL.style.t op = 0+'px';
parDivL.style.c lear = 'left';
parDivL.style.o verflow ='auto';
parDivL.style.s tyleFloat = 'left';
parDivL.style.h eight = appHeight+'px';


parDivR.style.m argin = 0+'px';
parDivR.style.w idth = '100%';
parDivR.style.p osition = 'relative';
parDivR.style.p adding = 0+'px';
parDivR.style.l eft = 0+'px';
parDivR.style.t op = 0+'px';
parDivR.style.c lear = 'left';
parDivR.style.o verflow ='auto';
parDivR.style.s tyleFloat = 'left';
parDivR.style.h eight = appHeight+'px';

}


note that the xhtml isn't compiled so the trees won't be visible, however if you fill the divs with a large amount of text or a big image, the div won' t remain encapsulated in 100% of the page but stretches well beyond that
which is infact the problem once the javascript is applied. prior to the javascript, the css does it's job.

thanks again in advance!

Joe Estes
Jan 11 '07 #3
b1randon
171 Recognized Expert New Member
the source xhtml portion with the problem divs:
-------------------------------------------------------------------

<table width="100%" border="0" cellspacing="0" cellpadding="0" >
<tr valign="top">
<td width="32" background="ima ges/layout/bdlft.jpg"><img src="images/layout/bdlft.jpg" width="32" height="10" /></td>
<td width="50%">
<div id="roadmapTree Div" class="divs">
<t:tree2 id="roadmapTree " value="#{roadma pTreeBean.treeM odel}" var="_node" varNodeToggler= "t" showLines="fals e" org.apache.myfa ces.tree2.CLIEN T_SIDE_TOGGLE=" true" org.apache.myfa ces.tree2.SHOW_ ROOT_NODE="true " org.apache.myfa ces.tree2.SHOW_ NAV="true">
<ims:tnc entity="${_node }" fieldName="fld1 "/>
<ims:tnc entity="${_node }" fieldName="fld2 "/>
<ims:tnc entity="${_node }" fieldName="fld3 "/>
<ims:tnc entity="${_node }" fieldName="fld4 "/>
<ims:tnc entity="${_node }" fieldName="fld5 "/>
<ims:tnc entity="${_node }" fieldName="fld6 "/>
<ims:tnc entity="${_node }" fieldName="fld7 "/>
<ims:tnc entity="${_node }" fieldName="fld8 "/>
<ims:tnc entity="${_node }" fieldName="fld9 "/>
<ims:tnc entity="${_node }" fieldName="fld1 0"/>
<ims:tnc entity="${_node }" fieldName="fld1 1"/>
</t:tree2>
</div>
</td>
<td width="1" bgcolor="#867F8 7"><img src="images/layout/divider.jpg" width="1" height="1" /></td>
<td width="50%">
<div id="auditTreeDi v" class="divs">
<t:tree2 id="auditTree" value="#{auditT reeBean.treeMod el}" var="_node" varNodeToggler= "t" showLines="fals e" org.apache.myfa ces.tree2.CLIEN T_SIDE_TOGGLE=" true" org.apache.myfa ces.tree2.SHOW_ ROOT_NODE="true " org.apache.myfa ces.tree2.SHOW_ NAV="true">
<ims:tnc entity="${_node }" fieldName="fld1 "/>
<ims:tnc entity="${_node }" fieldName="fld2 "/>
<ims:tnc entity="${_node }" fieldName="fld3 "/>
<ims:tnc entity="${_node }" fieldName="fld4 "/>
<ims:tnc entity="${_node }" fieldName="fld5 "/>
<ims:tnc entity="${_node }" fieldName="fld6 "/>
<ims:tnc entity="${_node }" fieldName="fld7 "/>
<ims:tnc entity="${_node }" fieldName="fld8 "/>
<ims:tnc entity="${_node }" fieldName="fld9 "/>
<ims:tnc entity="${_node }" fieldName="fld1 0"/>
<ims:tnc entity="${_node }" fieldName="fld1 1"/>
</t:tree2>
</div>
</td>
<td width="32" background="ima ges/layout/bdrt.jpg"><img src="images/layout/bdrt.jpg" width="32" height="10" /></td>
</tr>
</table>

again the css is:
------------------------

.divs {
overflow: auto;
height: 400px;
margin: 0px;
padding: 0px;
position: relative;
left: 0px;
top: 0px;
clear: right;
float: left;
width: 100%;
}

and the javascript that manipulates the divs once the page is loaded:
--------------------------------------------------------------------------------------------------

function resizeTreeDivs( LTree, RTree){
//these two trees are spans
var winHeight = document.docume ntElement.clien tHeight;
var appHeight = winHeight -189;
var parDivL = LTree.parentNod e;
var parDivR = RTree.parentNod e;

parDivL.style.m argin = 0+'px';
parDivL.style.w idth = '100%';
parDivL.style.p osition = 'relative';
parDivL.style.p adding = 0+'px';
parDivL.style.l eft = 0+'px';
parDivL.style.t op = 0+'px';
parDivL.style.c lear = 'left';
parDivL.style.o verflow ='auto';
parDivL.style.s tyleFloat = 'left';
parDivL.style.h eight = appHeight+'px';


parDivR.style.m argin = 0+'px';
parDivR.style.w idth = '100%';
parDivR.style.p osition = 'relative';
parDivR.style.p adding = 0+'px';
parDivR.style.l eft = 0+'px';
parDivR.style.t op = 0+'px';
parDivR.style.c lear = 'left';
parDivR.style.o verflow ='auto';
parDivR.style.s tyleFloat = 'left';
parDivR.style.h eight = appHeight+'px';

}


note that the xhtml isn't compiled so the trees won't be visible, however if you fill the divs with a large amount of text or a big image, the div won' t remain encapsulated in 100% of the page but stretches well beyond that
which is infact the problem once the javascript is applied. prior to the javascript, the css does it's job.

thanks again in advance!

Joe Estes
Joe, if you don't want your divs to grow to fit the content you should change your overflow style. The possible values are visible, hidden, scroll and auto. Try hidden or scroll to keep your divs the same size.
Jan 11 '07 #4
atma86
5 New Member
i changed it to scroll, and the app still stretches beyond 100% of the page.

again this only happens after i edit the divs with javascript

when the divs are set in the css, everything stay intact at 100% on the page. any suggestions?
Jan 12 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

14
2494
by: Brandon Hoppe | last post by:
I'm trying to change the src of an ilayer in the parent document from a link inside the ilayer. I'm not able to get it to work. All that happens is Netscape 4 crashes. This is for Netscape 4 only. For example, here is the main page: <html> <head> <script type="text/javascript">
4
1303
by: JezB | last post by:
I have a DIV which I want to automatically resize when the user resizes the browser. The width setting is easy - I want it to appear on the left hand side of the page and take up 50% of the screen so I set width:50%. The height is more tricky since I want to size it from it's rendered Y-position (which is not 0) down to the bottom of the browser. Hence if the user resizes downwards the DIV should expand itself to fit the height...
2
1006
by: John Blair | last post by:
Hi, When i run my asp.net page - i would like the browser to display the page in full screen - i.e. width 100% and height 100% of the v.d.u. - how do i achieve this? Thanks a lot!
1
4520
by: rbinington | last post by:
Hi, I am trying to write a DNN module that has the ability to insert articles into an article repository. I want the users to be able to move pages around and enter text into the FCKEditor. I want only one instance of the FCKEditor on the screen at one time so I make tabs that the user can click and I store the values in variables behind the scenes. I change the CSS class on the link that is the currently selected one. I have a really...
4
12524
by: reycri | last post by:
I have a page that works as I intend in IE but not in Firefox: <html> <head> <title>Overflow Test</title> </head> <body style='overflow:hidden; margin:0; padding:0;'> <table border='0' cellpadding='0' cellspacing='0' style='border-collapse:collapse; width:100%; height:100%;'> <tr><td colspan='2' style='height:3em; border-bottom:1px solid
1
6479
by: Mike Collins | last post by:
I am trying to create some pages and have them take 100% of the window, but I cannot get 100% to work. If I set the height of my div, the page displays a scroll bar and it looks like I set the height to about 150%. I tried using CSS, now I am trying tables. Can someone show me where I am mixing things up? Thanks. --Master Sheet <%@ Master Language="C#" AutoEventWireup="true" CodeFile="master.master.cs" Inherits="pts" %>
4
3318
by: gubbachchi | last post by:
Hi all, Please anybody help me solve this problem. I am stuck up with this from past 2 weeks. I am developing an application where, when the user selects date from javascript datepicker and enters the comments and clicks the save button then the date and the date will be stored in the mysql database. This is working fine. But my problem is when, after the user had made an entry the date in the calendar for which an entry has made should be...
1
3591
by: soms2m | last post by:
HELLO ALL, I want to fill the parent window height with respect to the sub window height which is loading using ajax (mootools). For example if the parent window height is normal and the loading child window height is 1200px (saying), when the child window load the height of the parent window changs but the backgorund color which is given 100% not fill the parent window. I have given my example codes, please give a solution as soon as...
7
4677
by: msoliver | last post by:
Okay, I believe this is one of the biggest issues found using CSS/DIV layout. But, I haven't found a non-Javascript solution. I would like two DIVs - first DIV, say with a height of 20px. The second DIV with a height of 100% (the rest of the viewport). If I do this <div style="height:20px>
0
8231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8672
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8330
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7153
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6107
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4075
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2603
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.