Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
12-26-2003, 02:40 PM #1
- Join Date
- Oct 2002
- São Paulo, BRAZIL
- Thanked 0 Times in 0 Posts
How can we get childNodes from a custom tag?
Hello dudes, i wrote a very simple HTML page to test some DOM features between Mozilla and IE. Mozilla is perfect everything went fine and i got the childNodes from my custom tag ( this tag i named <blah> ), inside this tag there is two <span>, that i retrieved. But with IE i really could figure out how its done! Here is my test below, i´d glad if someone point me how it could be done for IE also.
function test( )
var obj = document.getElementsByTagName( "blah" );
var span = null;
for ( var i = 0; i < obj.length; i++ )
if ( obj[ i ] != null )
alert( obj[ i ].getAttribute( "name" ));
for ( var j = 0; j < obj[ i ].childNodes.length; j++ )
span = obj[ i ].childNodes[ j ];
if ( span.nodeName == "SPAN" )
alert( span.getAttribute( "name" ));
<button type="button" name="btBlah" onClick="test( );">Test</button>
12-26-2003, 11:22 PM #2
When IE sees:
It represents it in the DOM like this:
empty HTML tag: CUSTOM
Text node: hello world
empty HTML tag: /CUSTOM
(they are all siblings), instead of the expected:
HTML tag: CUSTOM --> Text node: hello world
which is how Mozilla sees it.
The solution is to rely upon IE's HTML Namespaces, which is kind of a weird thing, but whatever.
In your <html> tag, include
Now, on custom tags, do:
<my:custom> instead of just <custom>
And that's it, parsing problem solved.