Wednesday, March 16, 2011

Javascript Programming

Static v Dynamic
JavaScript can do more than HTML because HTML is static, but JavaScript is dynamic, which means that it can react to viewer actions, such as clicking or rolling the mouse over an object. JavaScripts are often called "behaviors." A behavior is made up of a viewer "event" and a response or "action" by the programming. You can program a behavior to happen when a viewer clicks, or you can program it to happen when the viewer double clicks - that is the "event." When the "event" happens, the programming responds by showing something, like a drop-down menu, or by doing something, like playing a sound. With JavaScript, you site is "dynamic" because it responds to your viewer beyond regular hyperlinks!
Client-side programming v Server-side programming
JavaScript is a "client-side" programming language. Client-side means that the program code is sent into your computer with the rest of the web page code (usually HTML); then, your browser reads the code and does what it says. That means that on many sites with JavaScript, you can look at the programming code right along with the HTML by going to Edit -> View Source in your browser. You can usually tell if the code has JavaScript in it because the head tag will have a like that says script language="JavaScript". That is a good way to look at some working scripts. (Some websites do hide their JavaScript coding.)
JavaScript and Browsers
JavaScript is frequently used to do simple programming tasks because web viewers can turn JavaScript off on their computer, which means that all your hard programming work doesn't function when they view your site. JavaScript may be turned off for security, and there have been browsers that have JavaScript disabled as a default setting. Instead, we use JavaScript to enhance the functionality of a web page. For example, if you completely rely on JavaScript to validate your online forms, you have a security hole. If a viewer's JavaScript is turned off, it will by-pass your validation. So, you may also use a "server-side" programming language to double check the input.
Newer browsers generally have newer versions of JavaScript, which means there are more programming options. Some old browsers can't read JavaScript, or they can only read limited amounts of JavaScript. A browser that is JavaScript enabled can read some version of JavaScript.
Other Options
There are other types of scripting that look a lot like JavaScript. For example, the Flash program has its own scripting language called ActionScript, and many of the effects it produces in Flash are similar to what JavaScript can do on a page. For example, you can create a set of rotating images in JavaScript. The same thing can be done in Flash, except the Flash action is generally much smoother. If you learn JavaScript, you have the basics to start on many other scripting languages that are used for web pages.
Give it a try
You don't have to be Super-Geek to learn a little JavaScript! Here is a link to a few simple JavaScript exercises. All you need to do these exercises is Notepad (or another text editor  - do not use a word processor as the files may not be readable by the browser) and a browser. http://www.thecomputergal.com/Programming/JavaScript/8-HourSyllabus.htm
If you have never worked in HTML code before, read this page first to understand the steps of working between your text editor and your browser: http://www.thecomputergal.com/WebDesign/Lessons/UsingTextEditorSteps.htm
These materials are used in the 8-hour JavaScript course at Dickinson Lifelong Learning Center in Missoula, MT
Nora McDougall-Collins
Missoula, MT
Putting the world of computers into plain English

No comments:

Post a Comment