Javascript is a scripting language related to ActionScript. It is mostly used on websites.
We are going to predominately use javascript in these posts because it is very easy to play around with. You can write your code inside of an html document, and test it on your own computer before uploading it to a webserver. It also has some very nifty features for a programming language that makes it forgiving for people who have never written code before.
Your first program
So lets get started! Open up any text editor program. On a windows computer for instance, go to Start->Run and type in 'wordpad', then hit enter. It should open the default text editor for windows. Now copy paste this into the editor:
<html>This page should be viewable in any webbrowser. Simply save this file somewhere, such as 'test.html' and then open the file. Usually you can do this by just double clicking the file, or you can navigate to it directly from within the webbrowser.
<SCRIPT>
alert("Hello World!");
</SCRIPT>
</html>
When the page opens, it should display 'Hello World' in a little text box. Play around with it. Anything inside the script tags is javascript, and anything outside is normal html.
Tools
Before we go on too much further, there are some more tools that would be useful to have.
Important to any programming excercise is a good debugger. Javascript has one here. Firebug will let you step through javascript as it executes, as well as telling you when there are problems in your code. It is an add-on for firefox, but once the code works in firefox, with any luck, it will work in other browsers.
Another useful tool is a wordpad that provides syntax highlighting. Notepad++ can do this for javascript. If you are more comfortable with a normal notepad program though, there is no harm in just using that.
No comments:
Post a Comment