views:

52

answers:

3

We are using the getElementsByTagName function to find out domnodes present in the article. We found that IE and Firefox give different result for broken tag as below.

e.g. <a href="http://www.yahoo.com"&gt;Bypass HTML tags</ a> &nbsp; Complte 2 Fails

In IE : for above example we will get two nodes 'A' and '/'.

In firefox for above example we will get one node 'A'.

Both browsers should give same Dom elements.

Thanks in advance

+2  A: 

</ a> is not valid (X)HTML. You want </a>

no
+1 This is correct, when you close a tag like this in IE, it treats it as a `</>` tag e.g. `</ a="">`. Ridiculous, I know.
Andy E
Actually, IE got this one right... that's how it should be interpreted in HTML, just as in `<br />` the `/` is really a throw-away attribute... in regular xml (not xhtml) you could write `<br/>`, but for html compatibility you need the space so older browsers will treat the slash as an attribute.
no
A: 
el.getElementsByTagName('A') // gives Anchor text child nodes of el
el.getElementsByTagName('*') // gives All elements of el
Roki
A: 

https://developer.mozilla.org/en/DOM/element.getElementsByTagName see this link, this is for firefox.function has only one parameter

Sourabh