www.webdeveloper.com
Results 1 to 2 of 2

Thread: Cant get variable to display in html (very easy I'm sure)

Hybrid View

  1. #1
    Join Date
    Jun 2012
    Posts
    3

    Cant get variable to display in html (very easy I'm sure)

    Hello - My name is Max and i am new to Java Programming so thank you for helping me out.

    I have a file names maxcode.js which is a .txt file and contains the following 2 lines :

    var chameleon = "blue";
    Var Weight

    I have a file called about.html and in the head section of the document I have the code:

    <script type="text/javascript" src="maxcode.js"></script>>

    In the body section of about.html I have the following code:

    <script language="JavaScript">
    <!-- hide from older browser
    document.write(chameleon)
    //-->
    </script>

    At present nothing is displayed but by goal is to have the word blue displayed per the variables defined in the .js file. Can you help?

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,653
    document.write doesn't work in the body section because it tries to overwrite your document. remove your script in the head section

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles