What s JavaScript Good For?


What's JavaScript Good For?

There are many, many reasons for JavaScript's climbing popularity, and more are being invented all the time. Here are a few things that JavaScript can do for your web pagesthis is just a starter list, of course:

  • Livening pages up. The Internet already has too many static pages. Why add yours to the list? To get noticed, your page must be live, it must do something, or offer some service. What better way is there to liven pages up yourself than to use JavaScript, writing a short script that runs in the browser, right in front of the user ? JavaScript puts all the elements in a web pageand the web page itself!under your control.

  • Dynamic HTML. Dynamic HTML (DHTML) has become a catch-all word for an entire world of techniques, from image manipulations to positioning a web page's elements as you like; from using special DHTML objects for optical effects (such as the filter and transition objects in the Internet Explorer) to rewriting web pages on-the-fly . How do you make these things happen? JavaScript.

  • Data entry validation. Some web pages are designed to send data back to the web server, where that data is handled by Common Gateway Interface (CGI) programs such as Perl, Active Server Pages (ASP) programs, and Java Server Pages (JSP) programs. However, sending data back to the server takes time, and the server itself has limited resources. As a result, one popular use of JavaScript is to check the data a user has entered in a web page before that data is sent back to the server. Does the credit card number look like a valid number? Has the user entered his phone number? All that can be checked using JavaScript in the browser, after the user clicks the Submit buttonwe'll see how to use JavaScript to intercept the Submit button and check the data the user has entered before sending that data back to the server. (Note that to handle that data on the server, you have to have code on the server.)

  • Client-side "CGIs." Server-side programming can be difficultalthough JavaScript is starting to be supported on some servers, very few support it so far; and learning Perl, C++, ASP, and other programming languages is a more involved task than many people want to undertake. For that reason, their entire applications are written in JavaScriptno data has to be sent back to the server at all. They write entire mortgage calculators , news tickers, stock market trackers , all in JavaScript.

  • Unburdening busy servers. If your server has become so busy that it's a problem, why not shift some of the load to the browsers? JavaScript lets you do that, handling many programming tasks in the browser. Wasting your time processing loans for people not qualified? Maybe you should have JavaScript check them out first.

  • Handling cookies. A popular use of JavaScript is to work with cookies, storing information on the user's machine. Some people love cookies, some hate them, but there's no doubt that JavaScript can let you use them, all without any programming on the server at all. Want to record a user's special settings for your web page? A cookie will do that.

JavaScript can be used in millions of waysand is used in millions of web pages. We'll see all the ways listed previously in this book, and many more. In fact, we'll get started right now, creating our first script.



Inside Javascript
Inside JavaScript
ISBN: 0735712859
EAN: 2147483647
Year: 2005
Pages: 492
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net