You could do something like this:

var prev = this.el.previousSibling;
while (prev.tagName != 'DIV') {
    prev = prev.previousSibling;
}
var img = prev.getElementsByTagName('IMG')[0];

It's a bit hackish, but it should work.  Firefox seems to insert random
extra elements in the DOM like that.  I had the same problem with a <TR>
having childNodes that were text nodes (although the only elements on
the page were <TD> elements).  I'm not quite sure where they came from,
but I just removed all the non <TD> childNodes from the DOM altogether.
Everything rendered the same, and the code behaved as desired.

Greg

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Marco
M. Jaeger
Sent: Monday, November 07, 2005 12:54 AM
To: [email protected]
Subject: [Rails-spinoffs] IE vs. Firefox - little programming help
needed


Hello,

I was wondering whether somebody can give me a little hand on this:

I have the following code: "var img = 
this.el.previousSibling.getElementsByTagName('IMG')[0];"

While IE correctly returns the image object, Firefox returns an error.
What 
I discovered so far is that this.el.previousSibling returns the DIV tag
an 
IE which is correct - however, Firefox returns this: #text.

I was wondering whether there is some use of the prototype
cleanWhitespace 
but I couldn't make this to work yet.

Does anybody see a workaround/.

Thank you in advance for your help.

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's
FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to