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 3 of 3

Thread: newbie question

  1. #1
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    newbie question

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <script>
        window.onload= function() {
            alert(document.childNodes[1].childNodes[0]);
        }
    
    
    </script>
    
    
    </head>
    
    
    <body>
    <div>
    <h1>head</h1>
    </div>
    
    </body>
    </html>
    it output's [object HTMLHeadElement]

    but on document.childNodes[1].childNodes[1] it output's [object Text], why it doesn't outputs [object HTMLBodyElement]?

    the weird thing is that the [object HTMLBodyElement] is outputed on document.childNodes[1].childNodes[2], why?

    P.S. sory if my english is terible

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,460
    Thanks
    11
    Thanked 600 Times in 580 Posts
    use element.children to ignore whitespace nodes like the "\n\n\n\n" node at [1] separating the head [0] from the body [2].
    my site (updated 2014/10/20)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.3, IE11:9.2, IE9:2.7, IE10:2.6, FF:16.8, CH:47.5, SF:7.8, NON-MOUSE:37%

  • #3
    New to the CF scene
    Join Date
    Feb 2014
    Location
    Hà Nội
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have the same problem and I had solved it. Contact me, we'll discuss more about that.


  •  

    Posting Permissions

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