Re: firstNode problems
- From: Martin Kurz <info@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 29 Sep 2005 00:17:49 +0200
yawnmoth schrieb:
> I'm having some problems making the following work in both Internet
> Explorer and Firefox:
>
> http://www.frostjedi.com/terra/scripts/demo/childNodes.html
>
> What it should do (and indeed, what it does do, in Internet Explorer)
> is show a gray box. In Firefox, however, it shows a black box.
>
> To explain the commented out code... I've observed that using the
> childNode at index 1 does the samething that in Firefox that both
> firstChild and the childNode at index 0 do in Internet Explorer. As
> such, the above webpage can be easily made to work in Firefox, but once
> done, it won't work in Internet Explorer, and vice versa. I'd like to
> make it work in both browsers. Without giving the img element it's own
> id.
>
> Any ideas as to how I can do this would be appreciated. Thanks!
>
The problem here are the spaces between <div id="main"> and the img-Tag. Mozilla
handles these spaces as firstChild, so the img-tag ist childNodes[1]. But IE
seems to ignore these spaces, so the img-Tag is firstChild (childNodes[0]). The
easiest way would be eliminating these spaces, so both are having the img-Tag as
firstChild. If that's not possible, you could step through the childs with
nextSibling till you find the one you're looking for.
Greetings,
martin
.
- References:
- firstNode problems
- From: yawnmoth
- firstNode problems
- Prev by Date: Re: changing form values in a different window
- Next by Date: Re: firstNode problems
- Previous by thread: Re: firstNode problems
- Next by thread: Re: firstNode problems
- Index(es):
Relevant Pages
|