Share this Page URL
Help

Hour 1. Understanding JavaScript > Learning Web Scripting Basics - Pg. 2

2 Chapter 1. Understanding JavaScript The World Wide Web (WWW) began as a text-only medium--the first version of the HTML (Hyper- text Markup Language) specification didn't even have the capability to include graphics on a page. Although it's still not quite ready to give television a run for its money, the Web has come a long way. Today's Web sites can include a wealth of features: graphics, sounds, animation, video, and some- times even useful content. Web scripting languages, such as JavaScript, provide one of the easiest ways to spice up a Web page and to interact with users in new ways. The first hour of this book introduces the concept of Web scripting and the JavaScript language. It also describes how JavaScript, Java, and other Web languages fit into the scheme of things. The following topics will be covered in this hour: · · · · · · What Web scripting is, and what it's good for How scripting and programming are different (and similar) What JavaScript is How to include JavaScript commands in a Web page How different Web browsers handle JavaScript Choosing between JavaScript and alternative languages Learning Web Scripting Basics In the world of science fiction movies (and many other movies that have no excuse), computers are often seen obeying commands in English. While this may indeed happen in the near future, com- puters currently find it easier to understand languages like BASIC, C, and Java. If you know how to use HTML to create a Web document, you've already worked with one computer language. You use HTML tags to describe how you want your document formatted, and the browser obeys your commands and shows the formatted document to the user. Since HTML is a simple text markup language, it can't respond to the user, make decisions, or automate repetitive tasks. Interactive tasks like these require a more complex language: a pro- gramming language, or a scripting language. While many programming languages are complex, scripting languages are generally simple. They have a simple syntax, can perform tasks with a minimum of commands, and are easy to learn. Web scripting languages allow you to combine scripting with HTML to create interactive Web pages. Scripts and Programs A movie or play follows a script--a list of actions (or lines) for the actors to perform. A Web script provides the same type of instructions for the browser. A script in JavaScript can range from a single line to a full-scale application. (In either case, JavaScript programs always run within a browser.)