[Javascript] Changing a Div's Style- margin-left in IE5.5

none extstarrfam at cox-internet.com
Mon Jul 29 09:16:07 CDT 2002


What I want to do is move the div element which has the
image of a red ball in it.  I am trying to do so by
changing the style's margin-left value to 100 points.
I am using IE5.5.  Simply stated, I do not know how to
write the function moveBall.  Will someone please write
in the correct process for this funciton and give a few
comments to explain what they did.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
<html><head><title>Move a Ball Once in IE</title>
<script type="text/javascript1.2">
<!--

function moveBall( ) {
 document.all['red'].style.margin-left="100pt";
}

//-->
</script>
</head>
<body>
<div id="red" style="height:40px; width:40px;
margin-left:10pt; margin-top:40pt">
<img src="Ball- red.jpg" height="40" width="40"
id="redball" name="redball">
</div>
<form>
<input type="button" value="Move Ball" name="move"
id="move" title="Move" onclick="moveBall( )">
</form>
</body>
</html>





More information about the Javascript mailing list