Flash animation in JavaScript: Changing style Properties : JavaScript DHTML examples (example source code) » GUI Components » Animation

JavaScript DHTML










Java Products
Java Articles
JavaScript DHTML Home  »   GUI Components   » [  Animation  ]   

 
Flash animation in JavaScript: Changing style Properties

Please note that some example is only working under IE or Firefox.

 <!-- ***********************************************************
Example 5-9
"Dynamic HTML:The Definitive Reference"
2nd Edition
by Danny Goodman
Published by O'Reilly & Associates  ISBN 0-596-00316-1
http://www.oreilly.com
Copyright 2002 Danny Goodman.  All Rights Reserved.
************************************************************ -->
<html>    
<head>
<title>Changing style Properties</title>
<style type="text/css">
    #hot1 {color:red}
</style>
<script language="JavaScript" type="text/javascript">
// Set global variables
var totalCycles = 0;
var currColor = 0;
var colors, intervalID;
// Build array of color names
function init() {
    colors = ["red""green""yellow""blue"];
}
// Advance the color by one
function cycleColors() {
    // reset counter to 0 if it reaches 3; otherwise increment by 1
    currColor = (currColor == 3: ++currColor;
    // set style color to new color from array
    document.getElementById("hot1").style.color = colors[currColor];
    // invoke this function again until total = 27 so it ends on red
    if (totalCycles++ < 27) {
        intervalID = setTimeout("cycleColors()"100);
    else {
        clearTimeout(intervalID);
    }
}
</script>
</head>
<body onload="init(); cycleColors();">
<h1>Welcome to the <span id="hot1">Hot Zone</span> Web Site</h1>
<hr>
</body>
</html>
Related examples in the same category
1.  Circle Animation
2.  Right to left animation
3.  Flash animation in Javascript
4.  Animation along Straight Line
5.  Animation along a Circle
6.  Dancing Text (IE)
7.  Type Writer effect (IE)
8.  Type Writer Effect 1.1 (IE)
9.  JavaScript Ticker 1.2 (IE)
10.  Animation: Lottery Number Picker and Statistics
11.  Animation: wriggly
12.  Animation: welcome message
13.  Animation: trio
14.  Auto lotto dip
15.  Animation: snow
16.  Animation: star
17.  Animation: mouse doodle
18.  Animation: fireworks
19.  Animation: pretty
20.  Animation: Random Movement
21.  Lotto number draw
22.  Following eyes
23.  Animation: three eyes
24.  Animation: eyes
25.  Spot light
26.  Big static eyes
27.  Animation based on DIV with color flash
28.  Framework for creating CSS-based animations
29.  Animate dynamic element h1 tag
30.  Popup window animation (fly across screen)
31.  Animation on several images
32.  Using the onFilterChange Event Handler
33.  JavaScript Animation
34.  Periodically Updating the Text Displayed by an HTML Element
35.  Moving an Airplane Across a Web Page
36.  Link Hint Scroller 2.0 (IE)








Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.