Englisch
Deutsch
Englisch
Deutsch



<HTML>
<HEAD><TITLE>Im Kreis rotierende Elemente</TITLE>

<SCRIPT LANGUAGE = "JavaScript">
<!-- 
var r = 160;       // radius
var xoff = 180;    // x offset
var yoff = 170;    // y offset
var pi = Math.PI;  // get pi
var inc = pi / 45; // degrees per rotation cycle
var objects;       // objects to be rotated
var pos;           // position for objects

function initObjects() {
objects = new Array(); // define your objects
objects[0] = document.all.fly1.style;
objects[1] = document.all.fly2.style;
objects[2] = document.all.fly3.style;
objects[3] = document.all.fly4.style;

pos = new Array();
pos[0] = 0;
    for (i = 1; i < objects.length; i++) {
    pos[i] = parseFloat(pos[i-1]+((2*pi)/objects.length));
    }
rotateObjects();
}

function rotateObjects() {
    for (i = 0; i < pos.length; i++) {
    pos[i] += inc; objects[i].visibility = "visible";
    objects[i].left = (r * Math.cos(pos[i])) + xoff
    objects[i].top = (r * Math.sin(pos[i])) + yoff;
    }
setTimeout ("rotateObjects()", 75);
}
// -->
</SCRIPT></HEAD>

<BODY onLoad = "initObjects()">

<DIV ID = "fly1" STYLE = "position: absolute;">Element 1</DIV> 
<DIV ID = "fly2" STYLE = "position: absolute;">Element 2</DIV> 
<DIV ID = "fly3" STYLE = "position: absolute;">Element 3</DIV> 
<DIV ID = "fly4" STYLE = "position: absolute;">Element 4</DIV>

</BODY></HTML>
JavaScript-Beispiel: 004 | 15.11.99 | aktualisiert am 15.10.2003 | http://www.scharfsinnig.de/ |