Animation based on DIV with color flash : Animation « GUI Components « JavaScript DHTML






Animation based on DIV with color flash

 

/*
Examples From
JavaScript: The Definitive Guide, Fourth Edition

Legal matters: these files were created by David Flanagan, and are
Copyright (c) 2001 by David Flanagan.  You may use, study, modify, and
distribute them for any purpose.  Please note that these examples are
provided "as-is" and come with no warranty of any kind.

David Flanagan
*/
<html>

<!-- This div is the element we are animating -->
<div id="urgent"><h1>Red Alert!</h1>The Web server is under attack!</div>
<!-- This is the animation script for the element -->
<script>  
var e = document.getElementById("urgent");         // Get the element object
var colors = ["white", "yellow", "orange", "red"]  // Colors to cycle through
var nextColor = 0;                                 // Position in the cycle
// Evaluate the following expression every 500 milliseconds.  
// This animates the background color of the DIV element.
setInterval("e.style.backgroundColor=colors[nextColor++%colors.length];", 500);
</script>
</html>

           
         
  








Related examples in the same category

1.Attack animation
2.Circle Animation
3.Right to left animation
4.Flash animation in Javascript
5.Flash animation in JavaScript: Changing style Properties
6.Animation along Straight Line
7.Animation along a Circle
8.Dancing Text (IE)
9.Type Writer effect (IE)
10.Type Writer Effect 1.1 (IE)
11.JavaScript Ticker 1.2 (IE)
12.Animation: Lottery Number Picker and Statistics
13.Animation: wriggly
14.Animation: welcome message
15.Animation: trio
16.Auto lotto dip
17.Animation: snow
18.Animation: star
19.Animation: mouse doodle
20.Animation: fireworks
21.Animation: pretty
22.Animation: Random Movement
23.Lotto number draw
24.Following eyes
25.Animation: three eyes
26.Animation: eyes
27.Spot light
28.Big static eyes
29.Framework for creating CSS-based animations
30.Animate dynamic element h1 tag
31.Popup window animation (fly across screen)
32.Animation on several images
33.Using the onFilterChange Event Handler
34.JavaScript Animation
35.Periodically Updating the Text Displayed by an HTML Element
36.Moving an Airplane Across a Web Page
37.Link Hint Scroller 2.0 (IE)
38.Snow animation
39.Animation with JSTween