View Full Version : all.tags("UL")[0] returns NULL in IE8

12-07-2009, 02:06 PM
There is a line of code in function contained(e) that is used to handle the event of clicking on a <ul> item and converting from expanded to collapsed. (cur is the tag item corresponding to a <ul> item that is going to have its style altered to have a box of zero or non-zero and its icon changed from + to - or visa versa)

var foldercontent=ns6? cur.nextSibling.nextSibling : cur.all.tags("UL")[0]

When I run this under IE8 a null value is returned as the value of foldercontent but works just fine under FF 3.5.5.

Any clues why? Or what a coding fix might be?

12-07-2009, 11:36 PM
The value of ns6 is not shown in your code snippet. Typically this is a test for the document.getElementById method, is it? Sometimes it is a test for document.getElementById and not document.all. If that's the case, IE 8 which could use the cur.nextSibling.nextSibling method would be excluded from doing so. A lot of this could have to do with the rest of your code, including the rest of the script and the HTML markup it is being run against. If the markup is invalid, its possible that many browsers might have a problem with either method. However, it hasn't been since IE 4 that IE couldn't use the cur.nextSibling.nextSibling method. So, quite possibly you are just branching your code incorrectly. At the same time, siblings (as far as which exact nodes they are, sometimes empty text nodes are included, sometimes excluded) are not always seen the same in all browsers. In that case the document.getElementsByTagName method is often the best choice. If you want more help:

Please post a link to the page on your site that contains the problematic code so we can check it out.