advertisement

Hi, in this tutorial hopefully you will learn the basics of javascript.

First thing to know is javascript is a Client-Side programming language. That means it uses the users web browser to run the code. Second thing to know is there are TWO ways of including javascript in your web pages.

  1. The first way to include it in your page is to use script tags, for example:
    Take your basic HTML page structure:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Add your name to our database</title>
    </head>
    
    <body>
    </body>
    </html>
    

    The, find the head tag and inside it add:

    <script type="text/javascript">
    //Code goes here
    </script>
    
  2. The second way is to link to external jscript file. First thing create your file.js then in the head tag of the page you want to link it to add this:

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

    If you want to link it to a file on an external website:

    <script type="text/javascript" src="http://www.tutorialcode.com/file.js"></script>
    
  3. Now let’s start on some code. Say you want your website viewers to have javascript to view your content, you would use the document.write command. So in your head tag of your html page add this:

    <script type="text/javascript">
    document.write("Hello, world!")
    </script>
    

    Note: You do not have to add the ; on the end of javascript commands. The above code would write: Hello, world!

    Hopefully now you have some basic understanding of javascript, I may build on this and move on to move advanced stuff some time.

    Thanks for reading :)
    Mortisimus
    http://www.flashdoom.net

    advertisement