tailieunhanh - JavaScript Bible, Gold Edition part 198

JavaScript Bible, Gold Edition part 198. This book will bring programmers and non-technical professionals, including casual programmers and scripters, painlessly up to speed on all aspects of mastering JavaScript. Key topics include programming fundamentals, JavaScript language elements and how to use them effectively, and how to easily and efficiently add powerful new functionality to HTML documents and Java applets. | CD-462 Part VI Appendixes Example You can use The Evaluator to examine the protocol property of the image on the page. Enter the following statement into the top text box src NN2 NN3 NN4 NN6 IE3 J1 IE3 J2 IE4 IE5 Compatibility Example In the following example Listing 22-4 you see a few applications of image objects. Of prime importance is a comparison of how precached and regular images feel to the user. As a bonus you see an example of how to set a timer to automatically change the images displayed in an image object. This feature is a popular request among sites that display advertising banners. As the page loads a global variable is handed an array of image objects. Entries of the array are assigned string names as index values deskl desk2 and so on . The intention is that these names ultimately will be used as addresses to the array entries. Each image object in the array has a URL assigned to it which precaches the image. The page see Figure 22-1 includes two IMG elements one that displays noncached images and one that displays cached images. Under each image is a SELECT element that you can use to select one of four possible image files for each element. The onChange event handler for each SELECT list invokes a different function to change the noncached loadIndividual or cached loadCached images. Both of these functions take as their single parameter a reference to the form that contains the SELECT elements. To cycle through images at five-second intervals the checkTimer function looks to see if the timer check box is checked. If so the selectedIndex property of the cached image SELECT control is copied and incremented or reset to zero if the index is at the maximum value . The SELECT element is adjusted so you can now invoke the loadCached function to read the currently selected item and set the image accordingly. For some extra style points the BODY tag includes an onUnload event handler that invokes the resetSelects function.

TỪ KHÓA LIÊN QUAN