Navigation
Poll
Would you be an active poster if Ron's Guide had a message board?


Total Votes: 69
Comments: 20 — View
Past pollsPoll idea?
Rate Ron's Guide
Rate our resource at Bigwebmaster.com
Introduction to JavaScript
This tutorial will give you an introduction to JavaScript; what it is, what it can do, and more. It also covers some basic JavaScript concepts.

In this tutorial I hope to show you what Javascript is, and what it can do for you and your visitors.

Before I continue I must point out that i'm not an expert in javascript, the things you read from here are what i've read over the last year or so. Most of this introduction contains basic explanations and examples found across the internet and in books.

When you come to viewing an example of code, don't just copy and paste it, type it out. From doing this you will learn to debug your code and fix any problems that arise, just a small thing that I suggest, but if you want to copy and paste, feel free to do so. Tongue

What is Javascript and what can it do?

Javascript is a scripting language, which means that scripts included in the webpage are read by the web browser's javascript engine when the page is loaded. Javascript was created by Netscape and was orginally called Livescript.

There are loads of things you can do with Javascript to make your website more interesting for your visitors. From validating forms, interactive scripts, random images, popups, you can even make games using Javascript.

The Script Block.

In order to include Javascript in a web page, a script block must first be defined in the HTML code. The script block can be put anywhere within the HTML code, but usually it would go into the head part of the web page between the tags. When the web page loads in the browser it reads the code, so placing it in the head of the web page ensures that the Javascript code is read before the HTML content, though you can place a script block inside the tags.

Example of a script block:

<script type="text/javascript">
<!--

//-->
</script>

Note: you might see some script blocks that contain the language attribute, this was used to specify the scripting language but I believe it has been removed in HTML 4.0.

The actual code you make would go between <!-- and //-->. These are to hide the script from really old browsers that cannot interpret Javascript.

You may also separate the Javascript code from the HTML code by putting the Javascript code into a Javascript file. A Javascript file is just a text document with the Javascript code in it but without any <script> tags or HTML tags. A Javascript file is saved with the extension ".js".

To call the Javascript file to be loaded into the web page, you would use a script block like so:

<script type="text/javascript" src="http:// nextline
www.mydomain.com/myscript.js"></script>

Click to the next page to learn how to add comments to your javascripts.

« Previous [ 1 2 3 ] Next »
Discuss Tutorial: Introduction to JavaScript 0 Comments
There are currently no comments on this discussion.
Post a comment
Sorry, you must be a registered member to post comments.

If you would like to register, you can do so here.
If you already have an account, please login.