Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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>

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •