Results 1 to 4 of 4

Thread: Cannot get .js file to work

  1. #1
    Join Date
    Apr 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Cannot get .js file to work

    Hello all,
    I am starting on a final project for an entry level javascript class. The assignment does not seem to difficult but wouldn't you know that I am stuck on the very first part. I am supposed to have the very first line of the page <h1> my name</h1> in an external .js file. I cannot get it to work for some reason.

    This is what I have so far:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Web 115 Final Project</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />

    </head>

    <body>
    <script type="text/javascript" src="projectjs.js">
    </script>
    </body>
    </html>

    This is what the projectjs.js looks like:

    <h1>
    my name
    </h1>


    What am I doing wrong?

    Thank you for any help!

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    That is not JS that is html. You can use PHP's include/require or you could get that through an ajax request. You will need to change that file extension though as it is not js.
    Corrections to my coding/thoughts welcome.

  3. #3
    Join Date
    Apr 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I have to use an external javascript file. What has to be done to change it to a .js file.

  4. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    If this is your final project, id guess the purpose of the overall task is to recap on the things you've learned in earlier lessons and apply them to a final working scenario.

    Try to think back on what has been covered - check your notes and search related topics on the web - hopefully that will get the cogs turning and help you on your way.

    Here's a good js resource: http://www.w3schools.com/js/default.asp
    Work through a few of the chapters and you'll find your answer

    I'm a bit wary of forum help and school projects - I work in local government and education and I'm just mindful that asking others to do your class/home work for you (especially on such a well known resource as DD) can have a detrimental effect on your grades. I'm not saying that that's what you're doing but I'm just advising you to be careful of how much help you ask for or the line of questioning you take. This is the reason why my above response is not a straightforward answer and probably also why bluewalrus' reply is leaning towards hints only.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

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
  •