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
  1. #1
    New Coder
    Join Date
    Mar 2004
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    getting nodeValue in IE

    The following code works OK (i.e the alert displays "Testing") in Mozilla 1.6 but generates a javascript error in IE6. Any pointers as to why would be appreciated.

    <html>
    <head>
    <script language="javascript">
    function testingDOM(){
    var title;

    title = document.getElementsByTagName("title");
    alert(title.item(0).firstChild.nodeValue);
    }
    </script>
    <title id="title">Testing</title>
    </head>
    <body>
    <input type="button" value="click me" onClick="testingDOM()"/>
    </body>
    </html>


    Also, if i change my function to the following
    title = document.getElementById("title");
    alert(title.firstChild.nodeValue);

    it doesn't work at all.

    Why is this?

    Cheers

  • #2
    Regular Coder
    Join Date
    Feb 2003
    Posts
    638
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That could be related to this bug.
    Using the text property of title, or title property of document might be alternatives...
    Last edited by swmr; 03-29-2004 at 11:37 PM.
    hmm... ?

  • #3
    New Coder
    Join Date
    Mar 2004
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's very interesting, thanks.


  •  

    Posting Permissions

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