www.webdeveloper.com
+ Reply to Thread
Results 1 to 2 of 2
  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
    Russia, Rostov-on-Don
    Posts
    1,141
    document.write doesn't work in the body section because it tries to overwrite your document. remove your script in the head section
    use [code]YOUR CODE GOES HERE[/code] or burn in Hell

Thread Information

Users Browsing this Thread

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

     

Tags for this Thread

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
HTML5 Development Center



Recent Articles