www.webdeveloper.com
Results 1 to 5 of 5

Thread: html not running my script

  1. #1
    Join Date
    Jul 2012
    Posts
    3

    html not running my script

    Making a webpage and trying to use java to make the site a bit more managable. I'm new to both languages.
    Here's my java file I'm trying to run


    --------------------------------------------------------------------------------



    //Comic.js

    var Index= 0;

    var NumComics = 1;

    var ComicArray = new Array(NumComics);

    public class Comic {
    public int ComicNumber;
    public String ComicTitle;
    public String ComicDate;
    //constructor
    public Comic(int a, String t, String d)
    {
    ComicNumber = a;
    ComicTitle = t;
    ComicDate = d;
    }
    }


    function MakeArrays()
    {
    ComicArray[0] = new Comic(12001, "The Grass is Always Greener", "July 1 2012");
    }

    function WriteComicTitle()
    {
    MakeArrays();

    System.out.println(ComicArray[Index].ComicTitle);
    }

    --------------------------------------------------------------------------------


    Here's the html I'm using to do what needs to be done.


    --------------------------------------------------------------------------------



    <script type="text/javascript"src="Scripts/Comic.js">WriteComicTitle();</script>


    --------------------------------------------------------------------------------


    Other then the line above in my html, all the html code works (tables pics etc..) However my java is not running. Here's what I have accounted for already; file paths are all correct, I have gone over the sintax a dozens times. What am I doing wrong here. I'm an experienced c# and c++ if that helps anyone understand why I may be makeing a stupid mistake here. thanks in advance for the help.

    Dan

  2. #2
    Join Date
    Jan 2011
    Location
    United Kingdom, London
    Posts
    117
    Code:
    <script type="text/javascript" src="Scripts/Comic.js"></script>
    <script type="text/javascript">WriteComicTitle();</script>
    Javascript, jQuery / Prototype & PHP expert ready to complete your work on Freelancer.co.uk - Hire Me at https://www.freelancer.co.uk/users/1...&action=hireme

  3. #3
    Join Date
    Jul 2012
    Posts
    3

    Working

    Thanks for the help, I also discovered that part of my problem was that I was using classes wrong.

  4. #4
    Join Date
    Mar 2012
    Location
    Saint-Petersburg, Russia
    Posts
    97
    It looks like you mess java and javascript. Are you sure you know what are you doing at all? You could not insert java sources as scripts in html and javascript have no "classes" like java...

  5. #5
    Yeah, Java and Javascript are totally two different things. You may need to figure out their differences first!

Thread Information

Users Browsing this Thread

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

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