Click to See Complete Forum and Search --> : Random direction


mikemay
10-30-2004, 08:55 PM
Can any one help me on this i am tryin to move a image in random directions up and down i don't know if this is close or not but here what i have so far

Thanks

<html>

<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>move</title>

<script language="JavaScript" type="text/javascript"><!--
function moveObject(objectID) {{m=0;
e=document.getElementById("z");
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>
<style type="text/css" media="screen">
#image{
position: absolute;
top: 13px;
left: 7px;
width:800px;
height: 544px;
}

</style>

</head>
<body>
<img src="xlionpair.jpg" width="800" height="544" id="image" onclick="myfunction"/>

</body>
</html>

Charles
10-30-2004, 09:06 PM
You ought not to use comments to hide scripts in XHTML. You need to mark the section as CDATA, use external scripts or use HTML. The best solution is to use HTML.

mikemay
10-30-2004, 09:13 PM
Ah ok Thanks but dose anyone have any idea how to get the code to work

Charles
10-30-2004, 09:16 PM
Originally posted by mikemay
Ah ok Thanks but dose anyone have any idea how to get the code to work No matter what you do it will not work on XHTML browsers if you use those comments. In XHTML browsers are permitted to completely ignore comments.

mikemay
10-30-2004, 09:21 PM
ok do you have any suggestions on doing this in a different way

Thanks