I have this script
- Code: Select all
<html>
<head>
<title>Move Animation</title>
<style type="text/css">
body {
font:76% normal verdana,arial,tahoma;
}
h1, h2 {
font-size:1em;
}
#movObject {
position:absolute;
left:0px;
top:8em;
width:5em;
line-height:3em;
background:#99ccff;
border:1px solid #003366;
white-space:nowrap;
padding:0.5em;
}
</style>
<script type="text/javascript">
var mov = null;
function doMove() {
mov.style.left = parseInt(mov.style.left)+1+'px';
setTimeout(doMove,20);
}
function init() {
mov = document.getElementById('movObject');
mov.style.left = '0px';
doMove();
}
window.onload = init;
</script>
</head>
<body>
<h1>Wazup</h1>
<h2>How can i make it stop half way?</h2>
<div id="movObject">
I am mov.
</div>
</body>
</html>
And i want to make the block stop moving half way (and startmoving the other way) but for right now how can i make it stop i know i have to check for when the style.left = 50% of the screen width with "IF" maybe but i cant look up how to do it because my laptop is on reserve power and i thought i would right this really fast. I will reply when i find charger.
Thanks,



