Setinterval() Not Working On Firefox
Hi i'm quite new to java script and for some reason setInterval does not seem to work when i run this code on firefox. Ive tried running it on Microsoft edge but it still does not
Solution 1:
document.write(
is 1990's code - don't use it at all ... also setInterval("printTime()", 1000)
in code less than 30 years old is written setInterval(printTime, 1000)
functionprintTime(){
var now = newDate();
var hours = now.getHours();
var mins = now.getMinutes();
var seconds = now.getSeconds();
document.body.innerHTML += (hours+":"+mins+":"+seconds+"<br \>");
}
setInterval(printTime, 1000);//in ms
The reason document.write fails is documented here
Note: as document.write writes to the document stream, calling document.write on a closed (loaded) document automatically calls document.open, which will clear the document.
Post a Comment for "Setinterval() Not Working On Firefox"