Grow your CSS skills. Land your dream job.

external script help

  • # March 23, 2010 at 12:34 am

    if anyone pls help me out // pretty basic stuff.. still not god at it. :)
    html file

    Code:
    < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


    Hello World!! in html


    script.js file

    Code:
    window.onLoad = writeMessage;

    function writeMessage(){
    document.getElementById(‘helloMessage’).innerHTML = “Hello There!! Ext. JavaScript”;

    }

    # March 26, 2010 at 2:17 am

    All function calls in javascript (and just about any language you’ll find) require parentheses. Therefore, your line:

    Code:
    window.onload = writeMessage;

    should be written as:

    Code:
    window.onload = writeMessage();

    Also, the line in your HTML file’s internal script:

    Code:
    document.getElementById(“hello”).innerHTML;

    is doing nothing. You don’t have an element with an id of "hello", and even if you did, innerHTML takes the value between the open and close tags and gives it back to you. In this case, you’re not doing anything with it, simply reading it.

    I hope this helps.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".