webpage help

phragle

Charter Member
anybody semi decent on making webpages?? Im doing a new project at school, and need to find the code or script to make something move when you point the mouse at it, so it 'dodges' the cursor preventing you from actually clicking on it.

Thanks
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en-US">
<head><title>Click the Button</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript"><!--
function moveObj(obj){
var w = 600, h = 400;
newWidth = Math.floor(Math.random()*w);
newHeight = Math.floor(Math.random()*h);
obj.style.position="absolute";
obj.style.left=newWidth+"px";
obj.style.top=newHeight+"px";
}
function checkObj(event,obj){
var top = obj.style.top.split("px")[0];
var left = obj.style.left.split("px")[0];
if(top+5 > event.y || left+5 > event.x){moveObj(obj);}
}
window.setTimeout("checkObj(event,document.forms[0].elements[0]", 1);
document.onkeydown = function(){return false;}
//--></script>
</head>
<body onMouseMove="checkObj(event,document.forms[0].elements[0]);" onKeyPress="return false;">
<form action="" name="frm"><div>
<input type="button" value="Click Me Phragle!" onMouseOver="moveObj(this);" onClick="alert('Good Job');">
</div></form>
</body></html>

Test it here: http://jmarshall.com/easy/html/testbed.html
 
ok, I have the code adjusted so the speed and movement is fluid and can be ajusted for the frame size (damn, it's been 10+ years since I have messed with code) can I change the input type to .gif the value= filename as long as it's in the same directory?? that tested ok with a bogus file name displaying a red X so I believe it will work???? thanks for the code..I searched for almost 2 hours trying to find it this afternoon.
 
You want the button to be the picture and when they onMouseOver it moves?

That was kind of random- if it is a picture you may want to slow it down where it just bounces around to another spot vs shooting all over the place
 
it's actually going to be a word, most likely in the form of a transparent .gif

itt's a scool project like I said, so it's going to have a button of the side frame that says "find the truth" then opens up frame with work that says click on "truth" to learn more with a decent sized colotfull "truth" under that..so they go to click on it, but the truth avoids them by moving about the page.
 
Im getting close, still havent been able to test, won't start real construction untll this weekend. just trying to get the tools I will need.
 
Back
Top