Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript external script help

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #28489
    idavid
    Member

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

    Code:




    Chapter 3

    Hello World!! in html


    script.js file

    Code:
    window.onLoad = writeMessage;

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

    }

    #72979
    Democritus
    Member

    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)
  • The forum ‘JavaScript’ is closed to new topics and replies.