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

Chapter 2. Creating Your First Scripts > More JavaScript Examples

More JavaScript Examples

My goal in this chapter is not only to show you the basics of constructing scripts, but also to give you hints about the kinds of things you can do with JavaScript. To that end, this section presents three more simple examples that use JavaScript in different ways, and that also provide you with useful techniques that you can immediately incorporate into your own pages.

Example #2: Writing Data to the Page

One of JavaScript's most powerful features is the capability to write text, data, and even HTML tags to the Web page on-the-fly. That is, the text (or whatever) gets inserted into the page when a Web browser loads the page. What good is that? For one thing, it's ideal for time-sensitive data. For example, you might want to display the date and time that a Web page was last modified so that visitors know how old (or new) the page is. Listing 2.2 shows just such a script.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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