wuffy77
02-05-2008, 04:15 PM
Can anyone tell me what I've done daft with this script?
I'm trying to get the div height to gradually increase on loading the page? It works but it's just suddenly appearing.
<html>
<head>
<script type='text/javascript'>
function setdistance()
{
var distance = 300; //distance in miles
var distancepixels = 500; //height of route in pixels
var distancemiles = 750; //distance of the jouney in miles
for (i=0; i<=distance; i++)
{
progress=(distancemiles/distancepixels)*i;
document.getElementById('route').style['height']=progress;
}
}
</script>
<style>
.mapbg
{
width: 300px;
background-color: red;
}
</style>
</head>
<body onload="setInterval('setdistance()', 500)">
<div class="mapbg" id="route" style="height:0px">
<img src="file:///J:/1. Katie's Work/RBS/RER charity walk/map.png">
</div>
</body>
</html>
I'm trying to get the div height to gradually increase on loading the page? It works but it's just suddenly appearing.
<html>
<head>
<script type='text/javascript'>
function setdistance()
{
var distance = 300; //distance in miles
var distancepixels = 500; //height of route in pixels
var distancemiles = 750; //distance of the jouney in miles
for (i=0; i<=distance; i++)
{
progress=(distancemiles/distancepixels)*i;
document.getElementById('route').style['height']=progress;
}
}
</script>
<style>
.mapbg
{
width: 300px;
background-color: red;
}
</style>
</head>
<body onload="setInterval('setdistance()', 500)">
<div class="mapbg" id="route" style="height:0px">
<img src="file:///J:/1. Katie's Work/RBS/RER charity walk/map.png">
</div>
</body>
</html>