Code:
<html>
<head>
<script type="text/javascript">
// Delay for a number of milliseconds
//Function to delay the execution, this is not as the setTimeout() which will continue
//the execution of next statement without waiting to return the funciotn call
function delay(delayTime) {
var start = new Date().getTime();// set the start time for counting
while (new Date().getTime() < start + delayTime); //looping till the expected delay time matches..
}
</script>
</head>
<body>
<h1>Delay 7sec!</h1>
<script type="text/javascript">
alert("Start");
delay(7000);
alert("ended");
</script>
</body>
</html>
No comments:
Post a Comment
Thank you.