I'm trying to make a function that increases the webkit-Opacity when the page loads.
But first problem is that the function don't overwrite the element style before the for loop is finished, and the setTimeout don't work in the loop!!
Are there any Ideas how to make this work?
<script language="JavaScript">
function fadein()
{
Val = 0.0;
while(Val < 0.6)
{
document.getElementById("fadeDiv").style.webkitOpacity = Val;
setTimeout(Val += 0.1, 1000);
}
}
</script>
</head>
<body onload="fadein()">
<div ID="fadeDiv" style="-webkit-opacity: 0.0; width:100%; height: 100%; background-color: red">
Welcome to my Homepage!
</div>
</body>
</html>


Sign In
Create Account


Back to top










