Brilliant Java Script

By Ken Bluttman
June 2009
Pearson / Prentice Hall
ISBN: 9780273721536
276 Pages, Illustrated
$52.50 paper original


If you are designing websites and need an introduction to programming with the scripting language of the Web, Brilliant Javascript will show you how to use basic javascript programming to improve the functionality and design of your webpages, validate forms, detect browsers, create cookies, and much more.

Summary

JavaScript is a critical component of nearly all web pages and web applications, and is the most popular scripting language on the internet, working in all major browsers, such as Internet Explorer, Mozilla, Firefox, Netscape, and Opera.

It is a very powerful language but often overlooked as such. For years it has been used primarily for two things – validating form entries, and image rollovers. Yet there is much more under the hood. JavaScript is as powerful and comprehensive as any other development language.

JavaScript gives HTML designers a programming tool- HTML authors are normally not programmers, but JavaScript is a scripting language with a very simple syntax! Almost anyone can put small "snippets" of code into their HTML pages. Brilliant JavaScript will take the reader through the necessary introductory material, and build on this to present practical applicable methods involving text, maths and numbers, and much more. Further tips will be presented in boxouts and text alerts .

The book will follow a progression of knowledge; however will be modular in approach. A reader can jump right to the task(s) they need to learn and use. The step by step approach will make it easy to follow how JavaScript is written and implemented – something that many developers struggle with when it comes to JavaScript’s cryptic syntax.

Contents

1. Getting started with JavaScript

Write a basic script

Place your script in the head section

Place JavaScript in the web page body

Use an external JavaScript file

New concepts

Test a condition to determine the output

How to use conditional testing

Getty loopy

Use a loop to run repetitive actions

Break out of a loop

Debugging JavaScript

Understand the difference between comparison and assignment

2. Working with text

Typical text applications

Count the characters in a text string

Something to consider

Get a part of a text string

Find where a string starts inside a larger string

Out with the old, in with the new

Combining text

Breaking up is easy to do

3. Working with numbers and mathematics

Operate the operators

Basic maths

Following operator order

Rounding it out

Finding the lowest and highest values

Getting powered up

Random number generation

4. Calculating dates and times

What day and time is it?

Working with the month, day and year

Right on time

Getting granular with milliseconds

Counting elapsed days

Calculating the number of days till a future date

5. Getting organised with arrays

Creating an array

Working with array elements

Sorting an array

Combining arrays

Multidimensional arrays

6. Validation

Basic text entry validation

Validating an email address

Validating radio buttons and check boxes

Validating dates

Further validation issues

7. Applying JavaScript actions

Events are always happening

Update one select list based upon the selection in a different select list

Navigate to another website from making a list selection

Show or hide part of a page

Smart entry

Highlight where the entry is going

8. Enhancing the Web page

Personalisation

Keeping track of time spent on a web page

Providing a print button

Providing font resizing

Controlling page colours

9. Working with text effects

Stretching and contracting text

Scrolling text in the title bar

Whatever happened to scrolling in the status bar

Scrolling text on a button

Displaying text, typewriter style

Generating random text

10. Working with images

Preloading images

Image rollovers

Showcase photographs in a marquee

Zooming in on an image

11. Windows, pages, popups and prompts

Writing content to the browser

Alerts, prompts and confirms

Opening windows

Opening a new blank window

Planning for different screen sizes

12. Fancy and fun animation

Page transitions

Mouse trails

Bouncing a ball

Combining transitions and rollovers

13. Getting to know DOM (the Document Object Model)

A bit of DOM

Understanding the relationships of elements

Using the DOM to change elements

14. Using Ajax for fast server interaction

Saving page update time with Ajax

Using Ajax to return filtered data

15. Security

Disabling the right mouse button

Same origin policy

Keeping your site out of the frame of another site

Making your code unreadable

16. A roundup of advanced techniques

Getting information about the browser and the screen

Using an image map to control page visibility

Catching errors

Using a JavaScript library

Jargon buster

Troubleshooting guide


Return to main page of Trans-Atlantic Publications