Publishers of technology books, eBooks, and videos for creative people

Home > Articles

  • Print
  • + Share This
This chapter is from the book

Putting More than One Script on a Page

Up to this point in the book, you've seen scripts that do one thing at a time. But in the real world, you're more likely to want to perform a variety of things using a script, or even have multiple scripts on one page. You might want to have a script that redirects the JavaScript-less user to an alternate page, check for a plug-in, and discover what browser the user has, all in one script. A good way to do multiple things on a page is to group the things that are appropriate to header scripts together, and group body script actions together as well. Script 3.11 shows you how to put the Script 3.2 and 3.7 examples together into one page. Figure 3.18 shows the result of the combined scripts.


Script 3.11 This script combines the features of Scripts 3.2 and 3.7 into one page.


Figure 3.18 Both the plug-in check and the function passing examples are shown in the resulting page.

  • + Share This
  • 🔖 Save To Your Account