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


Total Votes: 67
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.
Hello World.

For your first script we will look at the Javascript alert dialog box. Take a look at the script below, then I will explain it.

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

alert("Hello World");

//-->
</script>

For this small script we use the Javascript alert() function within the script block.

When the web page is loaded the Javascript code causes the browser to open an alert box containing your message withing the quotes. So that's all it is, to have your message appear just place it within the alert function inside quotes.

Note: It's good coding practice to end statements with the semi colon ;, although Javascript doesn't require it like some languages (PHP) it's good to get in the habit of adding it.

Variables.

What is a variable? A variable is a place in which you can store data.

When you come to naming variables you must be aware of certain things. A variable can have any letter, digit and even the underscore _ may be used, but the variable may not begin with a digit.

Examples of valid variables:

abcd
my_variable
var32123

To create a new variable, you use the Javascript "var" keyword. I'll show you with a small script.

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

var my_message = "My First JavaScript Variable!";
alert(my_message);

//-->
</script>

The text string is stored inside the variable called my_message.

The variable name is called to the Javascript alert function that we talked about earlier, so when you run the script you will get an alert box displaying the string which is stored in the variable.

That's all for this tutorial, I hoped it helped you get a basic understanding of Javascript.

« 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.