473,495 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

A question on offsetHeight.

dmjpro
2,476 Top Contributor
Have a look at my JavaScript code...
Expand|Select|Wrap|Line Numbers
  1. function resizeFrameToFitScreen(){
  2.             var outerFrameSet = window.parent.document.getElementById('outerFrameSet');
  3.             alert(parent.document.body.offsetHeight);
  4.             alert(document.body.offsetHeight);
  5.             var top_frame_percentage = Math.round((100/parent.document.body.offsetHeight)*(document.body.offsetHeight+40));
  6.             outerFrameSet.rows = top_frame_percentage+'%,'+(100-(top_frame_percentage+30))+'%,30%';
  7.  
  8.             window.parent._top_frame_percentage = top_frame_percentage;
  9.         }
  10.  
I am calling this function when a page is loaded. The page attached to a frame of a parent window. First alert shows the parent window offsetHeight, the actual one acquired by the parent window. And the second alert shows the actual height of the current window. If i don't add 40 with document.body.offsetHeight it would show me the scroll bars in the window, but i write this code to fit the current window according to the resolution. Where i am going wrong ?
Sep 29 '08 #1
2 4057
pronerd
392 Recognized Expert Contributor
If top_frame_percentage is in fact supposed to be a percentage of the child frame inside the parent frame then you should be dividing the child frame by the parent frame. The math should look like this.


Expand|Select|Wrap|Line Numbers
  1.  
  2.     var top_frame_percentage = (  document.body.offsetHeight / parent.document.body.offsetHeight  )* 100;
  3.  
  4.     top_frame_percentage =  Math.round( top_frame_percentage );
  5.  
  6.  
Sep 29 '08 #2
dmjpro
2,476 Top Contributor
If top_frame_percentage is in fact supposed to be a percentage of the child frame inside the parent frame then you should be dividing the child frame by the parent frame. The math should look like this.


Expand|Select|Wrap|Line Numbers
  1.  
  2.     var top_frame_percentage = (  document.body.offsetHeight / parent.document.body.offsetHeight  )* 100;
  3.  
  4.     top_frame_percentage =  Math.round( top_frame_percentage );
  5.  
  6.  
Is it not the same as ...
(100/parent.document.body.offsetHeight)*document.body.o ffsetHeight
?

Debasis Jana
Sep 29 '08 #3

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

Similar topics

3
6130
by: Danny | last post by:
Is there a way to find the size of a <div> element where the height either hasn't been specified or is set to 'auto'? document.getElementById('myId').style.height returns either nothing or...
10
12783
by: arkerpay2001 | last post by:
Layout Gurus, My program has divs that contain a single text node. I programatically set the myDiv.style.fontSize = "8pt"; When I call myDiv.offsetHeight, the number "14" is returned. Can...
3
4672
by: marchaos | last post by:
I'm retreiving the offsetHeight of an element in firefox and IE, but in some circumstances, the height is bigger in IE that what it is in firefox, causing problems. Is there something that could be...
1
5244
by: bensamuel | last post by:
hi .. I am using java scritp to generate rowws and columns for a table dynamically, but the offsetWidth and offsetHeigth methods return "0" for the dynamically created elements in IE6 .it works...
2
3980
by: laszlokenez | last post by:
Tested in IE7 and FF2. I have 2 frames, 2 similar tables in them, similar CSS. (I have 1px cellpadding, and 1px border aroud the cells. From one frame I read the offsetHeight of a cell...
4
13513
dmjpro
by: dmjpro | last post by:
HTML code <div id="dtls_DIV" style="background-color:#CCCCCC;border-style:solid;border-width:1px;border-color:#000000;display:none;position:absolute;height:180px;width:230px;overflow:auto"> ...
1
6136
by: bob2044 | last post by:
offsetHeight is not working in following code <script type="text/javascript"> function Coverdiv() { var standard=(document.compatMode=="CSS1Compat") ? document.documentElement:document.body;...
0
7120
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,...
0
6991
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7160
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,...
0
7196
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7373
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...
0
5456
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,...
0
4583
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1405
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 ...
1
649
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.