*_*

Tulos

Näkyypi siellä täällä, mikäli näkyy... klikkaamalla pysähtyy/jatkaa.

Koodi

Tämä tulee BODY-osastoon

<div id="img"
 style="position:absolute;"><img src="../kuvat/bouncewp.gif"
 onmousedown="pauseResume();" alt="*_*" width="25" height="32" /></div>
<script type="text/javascript">
//Original: Justin Arruda (JArruda@mindspring.com)
//Modified: Osmo Saarikumpu 2004-01-12
var isIE = document.all?1:0;
var isNN = document.layers?1:0;
var isGecko = navigator.product=="Gecko"?1:0;
var step = 1;
var delay = 30;
var height = 0;
var Hoffset = 32;
var Woffset = 25;
var yon = 0;
var xon = 0;
var pause = true;
var interval;
var xPos = 20;

if(isIE) {
	var yPos = document.body.clientHeight;
}
else if (isNN || isGecko) {
	var yPos = window.innerHeight;
}

function changePos() {

if(isIE) {
width = document.body.clientWidth;
height = document.body.clientHeight;
img.style.left = xPos + document.body.scrollLeft;
img.style.top = yPos + document.body.scrollTop;
}

else if (isNN) {
height = window.innerHeight;
width = window.innerWidth;
document.img.pageY = yPos + window.pageYOffset;
document.img.pageX = xPos + window.pageXOffset;
}

else if (isGecko) {
height = window.innerHeight;
width = window.innerWidth;
document.getElementById("img").style.left = xPos + window.pageXOffset;
document.getElementById("img").style.top = yPos + window.pageYOffset;
}

if (yon) {
yPos = yPos + step;
}
else {
yPos = yPos - step;
}
if (yPos < 0) {
yon = 1;
yPos = 0;
}
if (yPos >= (height - Hoffset)) {
yon = 0;
yPos = (height - Hoffset);
}
if (xon) {
xPos = xPos + step;
}
else {
xPos = xPos - step;
}
if (xPos < 0) {
xon = 1;
xPos = 0;
}
if (xPos >= (width - Woffset)) {
xon = 0;
xPos = (width - Woffset);
   }
}
function start() {
interval = setInterval('changePos()',delay);
}

function pauseResume() {
if(pause) {
clearInterval(interval);
pause = false;
}
else {
interval = setInterval('changePos()',delay);
pause = true;
   }
}
start();
</script>
Weppipakin kotisivulle