473,405 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

offsetHeight and offsetWidth not working in IE and Mozilla both

dmjpro
2,476 2GB
HTML code

Expand|Select|Wrap|Line Numbers
  1. <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">
  2.     <table id="dtls_TAB" border=0 cellpadding="2" cellspacing="2" width=100%>
  3.         <tr>
  4.             <td nowrap id="dtls_TD" class="searchbgcolor" style="background-color:#DDEEEE">Not Available<BR/></td>
  5.             <td align="right" valign="top"><input type=button class=button value="X" onclick="document.getElementById('dtls_DIV').style.display='none';" title="close the window"/></td>
  6.         </tr>
  7.     </table>
  8. </div>
  9.  
Javascript Code
Expand|Select|Wrap|Line Numbers
  1. function showList(value,obj){
  2.     alert(value);
  3.     var pos = findPos(obj);
  4.     var left = pos[0], top = pos[1];
  5.     var div_ref = document.getElementById('dtls_DIV');
  6.     if(value!='') document.getElementById('dtls_TD').innerHTML = value;
  7.     else document.getElementById('dtls_TD').innerHTML = 'Not Available</BR>';
  8.     div_ref.style.left = left+'px';
  9.     div_ref.style.top = top+'px';
  10.     var dtls_TAB = document.getElementById('dtls_TAB');
  11.     div_ref.style.height = (dtls_TAB.offsetHeight+10)+'px';
  12.     div_ref.style.width = (dtls_TAB.offsetWidth+10)+'px';
  13.     div_ref.style.display = 'block';
  14. }
  15.  
On first click(method call) it's not working on 2nd click(method call) it's working.
Why it's happening .....
Mar 3 '09 #1
4 13507
Dormilich
8,658 Expert Mod 8TB
how are these two codes related? the Javascript is not triggered as far as I see.
Mar 3 '09 #2
dmjpro
2,476 2GB
When onClick event fires from any element then it happens.
Actually i thought no matter from where the method called, that's why i didn't post the calling of method ;)

Actually what's happening ... offsetHeight and offsetWidth returns zero... :(
Mar 3 '09 #3
mrhoo
428 256MB
It looks like you are trying to get the offset size of an element whose style.display is 'none'.

offsets are figured from the rendered size of an element- the space it takes up in the browser window. If the display is none, it has no offset size, or 0.
Mar 4 '09 #4
dmjpro
2,476 2GB
Ah..aah...I see ..Thanks for your reply ;)
Mar 4 '09 #5

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

Similar topics

10
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...
1
by: Ned Baldessin | last post by:
Hi, I have reimplemented the non-standard <marquee> element (in a very simplified fashion), moving around a DIV using offsetParent and offsetWidth. It works fine in Mozilla (1.7.5) and Safari...
3
by: mscir | last post by:
I'm adding text to a div using innerHTML, and watching the width of the div using offsetWidth. In IE the offsetWidth increases when the div gets wider, but in Netscape 7.2 or Firefox 1.0.3 it...
1
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...
5
by: liketofindoutwhy | last post by:
for the code var node = document.getElementById("something") alert(node.offsetWidth) is very similar to node.clientWidth and node.scrollWidth I just wonder why offsetWidth is well...
2
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...
3
dmjpro
by: dmjpro | last post by:
I am testing the value of document.body.offsetWidth in Mozilla and IE. IE gets the desired value but Mozilla is not getting the desired value. Actually what happens, i want to position an element...
1
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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...
0
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
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...

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.