function moveIt() {
if (document.all) {
sphere.style.top = parseInt(sphere.style.top) + 10;
sphere.style.left = parseInt(sphere.style.left) - 25;
if (parseInt(sphere.style.left) < 0) {
sphere.style.left = 900;
}
if (parseInt(sphere.style.top) >600) {
sphere.style.top = 10;
}
}
setTimeout('moveIt()', 100);
}
//function number two
function moveItwo() {
if (document.all) {
sphere1.style.top = parseInt(sphere1.style.top) + 110;
sphere1.style.left = parseInt(sphere.style.left) - 225;
if (parseInt(sphere.style.left) < 0) {
sphere.style.left = 900;
}
if (parseInt(sphere.style.top) >600) {
sphere.style.top = 10;
}
}
}
}
<div id="sphere" style="position:relative; left:900px; top: 0px; width:15px; height:15px;"> <img src="Spear.gif" width="15" height="15"> <div id="sphere1" style="position:relative; left:900px; top: 0px; width:15px; height:15px;"> <img src="Spear1.gif" width="15" height="15">
<input type="button" value="do it" onclick="" onMouseOver="moveIt()"> <input type="button" value="do in" onclick="" onMouseOver="moveItwo()">
I wrote this a few years back with the idea of just one broswer IE for the sake of understanding JavaScript in it's simples form.
I'll write a cross browser version of this soon.