Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FireFox assigning DOM nodes to var 1

Status
Not open for further replies.

stormbind

Technical User
Mar 6, 2003
1,165
GB
This is working in Chrome, Opera and IE.

Can you please help to fix it in FF?

Code:
var els = document.getElementsByClassName('myClass');
 for (var i=0; i<els.length; ++i){
       var node = els[i];
       // FF falls here with TypeDefError:node is undefined
 
                 while (node.tagName.toUpperCase() != 'BODY') {
                       elLeft += node.offsetLeft;
                       elTop += node.offsetTop;
                       node = node.parentElement;
                   }
 }

The following shows the same issue. FF doesn't seem to like assigning DOM objects, but maybe its something else?
Code:
while (els[i].tagName.toUpperCase() != 'BODY') {
          elLeft += els[i].offsetLeft; // FF OK here
          elTop += els[i].offsetTop; // Still OK
          els[i] = els[i].parentElement; // FF falls here, TypeDefError
}

--Glen :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top