I was looking around for some code for a special purpose and found
this. Seems it should print "here we go" , pause 5 seconds, print "now
we are back". Instead, it pauses 5 seconds before printing both lines
with no pause between. Can someone please explain why it behaves that
way. I know in the case of "setTimeout " the only thing affected is the
function, etc. appearing as "setTimeout " arguments. But, this is just
straight code.
<body>
<script language='javas cript'>
document.write( 'here we go<br>');
pausecomp(5000) ;
document.write( 'now we are back');
function pausecomp(Amoun t)
{
d = new Date() //today's date
while (1<2)
{
mill=new Date() // Date Now
diff = mill-d //difference in milliseconds
if( diff > Amount ) {break;}
}
}
</script>
</body>
this. Seems it should print "here we go" , pause 5 seconds, print "now
we are back". Instead, it pauses 5 seconds before printing both lines
with no pause between. Can someone please explain why it behaves that
way. I know in the case of "setTimeout " the only thing affected is the
function, etc. appearing as "setTimeout " arguments. But, this is just
straight code.
<body>
<script language='javas cript'>
document.write( 'here we go<br>');
pausecomp(5000) ;
document.write( 'now we are back');
function pausecomp(Amoun t)
{
d = new Date() //today's date
while (1<2)
{
mill=new Date() // Date Now
diff = mill-d //difference in milliseconds
if( diff > Amount ) {break;}
}
}
</script>
</body>
Comment