Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    May 2004
    Location
    Minneapolis, MN, USA
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts

    <img /> element nodes sometimes counted as child nodes, sometimes not

    http://sethrasmussen.com/common/js/q-child-nodes.html

    I've posted about this before, but received no help. I've read around, asked others, and still find myself stumped, so I'm trying here again. Maybe my savior didn't see the thread before...

    I'm finishing off a function that will find <blockquote /> and <q /> elements with the cite attribute defined, and use that URI to construct a link to the quotation source. The blockquote section is working beautifully.

    For quotes, I want to use the existing quote text and basically turn that into the link. To do so, I am looping over the child nodes of a <q />, saving those text values into a temporary container that is then appended to the new <a /> which is in turn appended to the <q />.

    The problem is with <img /> elements for some reason. As you can see on the test page, if there is a mix of text nodes and <img /> element nodes, my script fails to grab the alt attribute of the <img />. Through some alerting, I've determined that in that instance, the script sees the proper amount of nodes, but just ignores the <img /> for some reason. If there quote contains nothing more than an <img />, the script works as intended.
    Last edited by ]|V|[agnus; 12-15-2004 at 08:01 PM.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Have you tried using cloneNode? Be much simpler..
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #3
    Regular Coder
    Join Date
    May 2004
    Location
    Minneapolis, MN, USA
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I dunno. Not really familiar with it. I'll heed you statement-as-question and look into it, though. Thanks.

  • #4
    Regular Coder
    Join Date
    May 2004
    Location
    Minneapolis, MN, USA
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That is indeed a much smarter approach, however I am still getting the same result in the case of a quote containing text and images. The only improvement is that now the case where the quote contains only the image is actually copying the image and not just the text.


  •  

    Posting Permissions

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