After being totally frustrated by what I believe to be a bug in Firefox’s Document Object Model (DOM) I found a very handy fix. Agave Group Design investigated this issue and realised that Firefox counts line breaks as a textNode and therefore can be returned in many situations as the next sibling rather than for example the next div.
The fix was fairly simple in the creation of the following function:
code
function getNextSibling(startBrother){
endBrother=startBrother.nextSibling;
while(endBrother.nodeType!=1){
endBrother = endBrother.nextSibling;
}
return endBrother;
}
endBrother=startBrother.nextSibling;
while(endBrother.nodeType!=1){
endBrother = endBrother.nextSibling;
}
return endBrother;
}
The full article can be found on the Agave Group Design website.


6 Comments Received
Hey this is just what I was looking for. Thanks
Thanks buddy…
I tried the code but to make it run I had to put 1 as String
function getNextSibling(startBrother){
endBrother=startBrother.nextSibling;
while(endBrother.nodeType!=”1″){
endBrother = endBrother.nextSibling;
}
return endBrother;
}
My Firefox version is 2.0.0.9
the problem with this code starts when the
startBrother.nextSibling = empty space, which in ie you can check it with “if(startBrother.nextSibling)” but with firefox there’s a bit of complex.. didn’t find the answer yet…
Just exploring some Javascript stuff. LOL, I accidently copied the code in comments, so it works. Same code works for previousSibling, only u have to chande the nextSibling to previousSibling. Great work!
Thanks.
so cool.. I like it. thanks.
Leave A Reply