Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-31-2004, 08:32 PM   PM User | #1
mikemay
New to the CF scene

 
Join Date: Oct 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
mikemay is an unknown quantity at this point
random direction

Hi everybody I am triyin to move a image in random direction when click on any help would be great thanks



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
function moveaway(){m=0;
e=document.getElementById("image");
if(h>700){h=h-50;m=1;}
if(h<50){h=h+50;m=1;}
if(v>350){v=v-50;m=1;}
if(v<50){v=v+50;m=1;}
if(!m){n=Math.random()*100-50;o=Math.random()*100-50;h=h+n;v=v+o;}
e.style.left = h + 'px';
e.style.top = v + 'px';
}
</script>
<style type="text/css">
#image {
position:relative;
width: 225px;
height: 148px;
float: left;
margin: 5px;
}
</style>

</head>
<body>
<img src="xlionsideways.jpg" alt="lion" id="image"/>
</body>
</html>
mikemay is offline   Reply With Quote
Old 11-02-2004, 12:09 AM   PM User | #2
Willy Duitt
Banned

 
Join Date: Sep 2003
Posts: 3,620
Thanks: 0
Thanked 0 Times in 0 Posts
Willy Duitt is an unknown quantity at this point
Not sure that I understand what you are trying to do here...

But h and v are undefined....

Try turning on IE javascript error notification under Tools --> Internet Options --> Advanced

Or try using Mozilla's Javascript Console so that you can be alerted to the errors which are bing thrown...

.....Willy
Willy Duitt is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:49 PM.


Advertisement
Log in to turn off these ads.