- Random Picture Rotation with JavaScript
- How the Rotating Images Code Works
- The Coding Plan
- Some Key JavaScript Concepts
- Detecting the Load Event
- Triggering the Function from the Load Event
- Generating Random Numbers
- Creating the Image Path
- DOM Scripting
- Assembling the Image Element
- Adding the Image Element to the Page
- Reviewing the Working Page
- Summary
Summary
JavaScript is a complex language, but it's easy and perfectly acceptable to collect scripts from the Web to study and use in your work. It's a great way to build your skills. Just make sure that you leave any credits in the code and follow any distribution agreements.
I hope that you find this scriptto which you're entirely welcometo be useful and inspiring in your work. Drop me an email message with any comments or ideas for future articles.
You can download a zip file of this example complete with images at http://www.stylinwithcss.com.
Charles Wyke-Smith is a web designer and user experience consultant based in Charleston, South Carolina. His third web development book, Scriptin' with JavaScript and Ajax, is scheduled for publication in September 2009. You can write to him at mailto:charles@stylinwithcss.com.