Make your own free website on Tripod.com
WELCOME TO THE WONDERFUL WORLD OF JAVASCRIPT
This page will touch on the basics of javascript. Javascript is a programming language, not a layout language like HTML. The neat thing about it is you can move things around on a page, and best of all, chat with it. It is compatible with HTML, so any tricks you learned there will still be useful.

The document - object model
Don't be afraid of this phrase, it means "the way things are named". Variable names in javascript are a lot like your mailing address, you are identified by your state, city, street and number, maybe by floor, etc. In a script, a reference to what is written in an input box may look like document.graphics.background.value this line refers to what is written in an input named background in a form named graphics. Many variables in javascript are arbitrary, but value always applies to an actual state (in this case, what's written).

Method is another scary word you may have read about. It refers to the various sub-programs that your scripts use. There are two types of methods that Javascript can recognise: functions, (methods you write), and ones that are built into the program you (or webtv in this case) are using. A function use may look like changeColors() or changeColors(this.form.red, this.form.blue, this.form.green) I recommend the first one, because it's easier to understand and debug. The stuff in paretheses can only be used in certain circumstances, it's handy but kind of tricky. I'll teach you how anyway, but now you can't say I didn't warn you ;)

"But all I want is a webtv chatroom!"

Do I hear you cry? Well it doesn't have all that much to do with javascript. The main tags are in ChatTutor. View the code to see what you need. The one that is a Javascript method is Chat.addChannelMessage() This is a method that is written into your box. If you put Chat.addChannelMessage("I can't type, yet I must chat") as the action of a form, or href="javascript:Chat.addChannelMessage("I can't type, yet I must chat") as the attribute of an Anchor (<A ...>...</A>) tag everybody will see exactly how witty you (me in this case) are. Kind of boring, but if the stuff in parentheses isn't in quotes, but refers to an input form element they will see the value of whatever you put there. In chat the value is usually found in a text input element. Sometimes two are added together.

Values can be either strings of words or numbers. if you enter a number into a text box it will automatically be a word. To convert it to a number, use the parseInt(the value of your input) method. Here's an examplet:
howMany = document.forms['numbers'].elements['someBox'].value;
plusTwo = parseInt(howMany) +2;
Chat.addChannelMessage(plusTwo)
You probably have no idea what that does :-P Just look for the parseInt(howMany) ...

I hope that's enough to get you started... at least you will be able to understand the terms most used in more technical tutorials. I'll be adding a few examples of scriplets that work, and hopefully you will be able to learn from example.