<html>
<head>
<script type="text/javascript">
var dir = 1;
function setSpace() {
var img = document.getElementById("compman");
var l = img.style.left.replace("px","").replace("pt","");
if ( l == "200" ) dir = -1;
if ( l == "0" ) dir = 1;
img.style.left = l*1 + 5*dir;
setTimeout("setSpace()", 50);
}
</script>
</head>
<body>
<img id="compman" style="position:relative; left:0" src="http://www.w3schools.com/jsref/compman.gif" alt="Computerman" width="107" height="98" />
<p>Some text. Some text. Some text. Some text.</p>
<input type="button" onclick="setSpace()" value="Set hspace and vspace" />
</body>
</html>
|