473,326 Members | 2,061 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,326 software developers and data experts.

Getting null value for div.offsetParent in Mozilla.

1
In my code i am trying to access offsetLeft and offsetTop values for a element which is a div, I use offsetParent property to obtain the same. The code i use is

this.tip.style.left = this.handle.offsetParent.offsetLeft + 'px';

After debugging i found the value of "this.handle.offsetParent" is set to null.

I have problems with Mozilla firefox. The code works absolutly fine with IE

My questions :-

1. When do we get element.offsetParent value as null.
2. Why do we get element.offsetParent value as null.
3. What is the difference between parentNode and offsetParent properties, why one should not be used for the other.
Mar 28 '07 #1
1 3604
mrhoo
428 256MB
offsetParent is an IE idiom.
this works in IE and the other browsers:
Expand|Select|Wrap|Line Numbers
  1. function whereAt(hoo){        
  2.     var T=0,L=0;    
  3.     while(hoo){
  4.         L+= ( hoo.offsetLeft)? hoo.offsetLeft: 0;
  5.         T+= (hoo.offsetTop)? hoo.offsetTop: 0;
  6.         if(hoo== document.body) break;
  7.         hoo= hoo.parentNode;
  8.     }
  9.     return [L,T];
  10. }
Mar 28 '07 #2

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

Similar topics

1
by: Jeff | last post by:
Hello all, I have an SQL Insert statement I'm trying to run via ExecuteNonQuery. It works fine so long as there are no nulls values. Here is the statement...(its a shortened version of what i...
3
by: Akhenaten | last post by:
I have the following function which works great except when I encounter a NULL value in my array ($aidlook) and then I get "wrong data type" errors. I thought about doing a NULL check and creating...
1
by: micdon143 | last post by:
In javascript, I have a function to add new tables. The id of the table is "myTable". When I tries to access it by using document.getElementById("myTable"), it is returning null... Please help
2
by: preeti13 | last post by:
Hi guys i am here with my another probelm please help me.trying insert the value into the data base but getting the null value error .I am getting thsi error Cannot insert the value NULL into...
5
by: cdavii | last post by:
Anyone have an idea why i get null values when i import data from a ms spread sheet in a sql tbl. The table elemet(Spread sheet) in question contains alpha numerics. The sql table is populated with...
13
by: jcato77 | last post by:
I am having trouble figuring out my code and was hoping someone could point me in the right direction. Below is my code what I need to due is create a method to add and display the value of the...
6
rajiv07
by: rajiv07 | last post by:
Hi to all I have an doubt on getting NULL value from mysql tables. If i fetch the null values it return empty string,Bt i want to get the NULL value as it is. Please Help on this. Regards...
0
by: rajesh0303 | last post by:
Iam get null values in the datakeynames AlertID,ItemID while executing the Insert Command....I am Inserting using Externel button Event.Here is the code of Gridiew ,Its datasource and the button...
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.