I want to drop a div down to a certain height to display some additional content. For that I wrote following dropbox() function:
<script type="text/javascript">
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}
}
function dropbox(element){
var obj = document.getElementById(element);
if(obj) {
var element = document.getElementById(element),
style = window.getComputedStyle(element),
height = style.getPropertyValue('height');
height = height.substring(0,2);
var i = 0;
for (i = height; i<200; i++)
{
sleep(100);
var tst = i+"px";
//alert(tst);
obj.style.height = tst;
}
//alert(i);
} else {
}
}
</script>
Now the problem I’m experiencing is, the box actually isn’t visible during the roll down process but only after the loop has completed but I want it to look like the “Check Availability”-box on http://www.thedana.com/. How do I get this accomplished?
Thank you!
Here is a sample code. It may help you