Results 1 to 2 of 2

Thread: all.tags("UL")[0] returns NULL in IE8

  1. #1
    Join Date
    Dec 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default all.tags("UL")[0] returns NULL in IE8

    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)

    Code:
    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?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •