• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 1. Jump-Starting JavaScript > What You Can Do with JavaScript That You ...

What You Can Do with JavaScript That You Can’t Do with HTML

The most important feature that JavaScript can add to a web site design is the capability to introduce dynamic interactivity into pages. The concept of dynamic interactivity implies change in response to an action. For example, a design might be one that seeks to engage the viewer in the page. By having page elements that respond to the viewer’s action, the designer can have a page that interacts with the viewer rather than just sitting there for the viewer to look at. In one respect, HTML sites are interactively dynamic because the viewer navigates to different places in the site depending on where she clicks on the page. However, the pages themselves are fairly static. With dynamic interactivity on a page, features of the page change as the user moves, clicks, or drags the mouse over the page.

Alerting the Viewer

A useful built-in function in JavaScript is the alert( ) function. This function sends a message to the page. The contents of the message can vary depending on what the user does, or the messages can be static. When the alert box appears with the message, the user clicks to close it. The following example is a very simple one that illustrates how to use a function in a script. Throughout the book, examples using the alert( ) function will help you understand JavaScript, and I think you will find it a good learning tool. Of course, you can use it in more sophisticated ways than what is presented here. When you start writing more complex functions, you will find the alert( ) function valuable in terms of pinpointing problem areas in the function.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint