Results 1 to 3 of 3

Thread: Simple DHTML not working

  1. #1
    Join Date
    Jun 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Simple DHTML not working

    Can anyone explain why this isn't working:

    <html>
    <head>
    <title>Test Page</title>

    <script language="javascript" type="text/javascript">
    function Init()
    {
    var foo = document.getElementById("title");

    foo.InnerText = "HELLO";
    }
    </script>
    </head>
    <body onload="Init();">
    <h1 id="title">Title</h1>
    </body>
    </html>

  2. #2
    Join Date
    Jun 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Nevermind. I just realized I was using InnerText instead of innerText. I've been in the world of Pascal casing for a while now.

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    "innerText" exists only in IE, and so should not be used. That should be written like this:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
        <head>
            <title>Test Page</title>
            <script type="text/javascript">
                function Init()
                {
                    var foo = document.getElementById("title");
                    foo.innerHTML = "HELLO";
                }
            </script>
        </head>
        <body onload="Init();">
            <h1 id="title">Title</h1>
        </body>
    </html>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •